Skip to content

Commit

Permalink
Moved Type implications into utility function.
Browse files Browse the repository at this point in the history
  • Loading branch information
hulpke committed May 1, 2018
1 parent 348e661 commit 425e74d
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 180 deletions.
5 changes: 5 additions & 0 deletions lib/grp.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3567,6 +3567,11 @@ DeclareOperation( "GroupWithGenerators", [ IsCollection ] );
DeclareOperation( "GroupWithGenerators",
[ IsCollection, IsMultiplicativeElementWithInverse ] );

#F MakeGroupyType( <fam>, <filt>, <gens>, <isgroup> )
# type creator function to incorporate basic deductions so immediate methods
# are not needed
DeclareGlobalFunction("MakeGroupyType");


#############################################################################
##
Expand Down
94 changes: 44 additions & 50 deletions lib/grp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -4291,6 +4291,39 @@ local s,b;
return s;
end );

#F MakeGroupyType( <fam>, <filt>, <gens>, <id>, <isgroup> )
# type creator function to incorporate basic deductions so immediate methods
# are not needed. Parameters are family, filter to start with, generator
# list, is it indeed a group (or only magma)?
InstallGlobalFunction(MakeGroupyType,
function(fam,filt,gens,id,isgroup)

if IsFinite(gens) then
if isgroup then
filt:=filt and IsFinitelyGeneratedGroup;
fi;

if Length(gens)>0 and CanEasilyCompareElements(gens) then
if id=false then
id:=One(gens[1]);
fi;
if id<>fail then # cannot do identity in magma
if ForAny(gens,x->x<>id) then
filt:=filt and HasIsTrivial and IsNonTrivial;
if isgroup and Length(gens)<=1 then # cyclic not for magmas
filt:=filt and IsCyclic;
fi;
else
filt:=filt and IsTrivial and HasIsNonTrivial;
fi;
fi;
elif isgroup and Length(gens)<=1 then # cyclic not for magmas
filt:=filt and IsCyclic;
fi;
fi;
return NewType(fam,filt);
end);

#############################################################################
##
#M GroupWithGenerators( <gens> ) . . . . . . . . group with given generators
Expand All @@ -4300,31 +4333,12 @@ InstallMethod( GroupWithGenerators,
"generic method for collection",
[ IsCollection ],
function( gens )
local G,fam,typ,id;

fam:=FamilyObj(gens);
local G,typ;

typ:=IsGroup and IsAttributeStoringRep
and HasIsEmpty and HasGeneratorsOfMagmaWithInverses;

if IsFinite(gens) then
typ:=typ and IsFinitelyGeneratedGroup;

if Length(gens)>0 and CanEasilyCompareElements(gens) then
id:=One(gens[1]);
if ForAny(gens,x->x<>id) then
typ:=typ and HasIsTrivial and IsNonTrivial;
if Length(gens)<=1 then
typ:=typ and IsCyclic;
fi;
else
typ:=typ and IsTrivial and HasIsNonTrivial;
fi;
elif Length(gens)<=1 then
typ:=typ and IsCyclic;
fi;
fi;
typ:=NewType(fam,typ);
typ:=MakeGroupyType(FamilyObj(gens),
IsGroup and IsAttributeStoringRep
and HasIsEmpty and HasGeneratorsOfMagmaWithInverses,
gens,false,true);

G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens));
Expand All @@ -4336,31 +4350,12 @@ InstallMethod( GroupWithGenerators,
"generic method for collection and identity element",
IsCollsElms, [ IsCollection, IsMultiplicativeElementWithInverse ],
function( gens, id )
local G,fam,typ;

fam:=FamilyObj(gens);
local G,typ;

typ:=IsGroup and IsAttributeStoringRep
and HasIsEmpty and HasGeneratorsOfMagmaWithInverses and HasOne;

if IsFinite(gens) then
typ:=typ and IsFinitelyGeneratedGroup;

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;
fi;
else
typ:=typ and IsTrivial and HasIsNonTrivial;
fi;
elif Length(gens)<=1 then
typ:=typ and IsCyclic;
fi;

fi;
typ:=NewType(fam,typ);
typ:=MakeGroupyType(FamilyObj(gens),
IsGroup and IsAttributeStoringRep
and HasIsEmpty and HasGeneratorsOfMagmaWithInverses and HasOne,
gens,id,true);

G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens),
Expand All @@ -4376,15 +4371,14 @@ local G,fam,typ;

fam:= CollectionsFamily( FamilyObj( id ) );

typ:=IsGroup and IsAttributeStoringRep
typ:=IsGroup and IsAttributeStoringRep
and HasGeneratorsOfMagmaWithInverses and HasOne and IsTrivial and
HasIsEmpty and HasIsNonTrivial;
typ:=NewType(fam,typ);

G:= rec();
ObjectifyWithAttributes( G, typ,
GeneratorsOfMagmaWithInverses, empty,
IsEmpty,false, IsNonTrivial,false,
One, id );

return G;
Expand Down
117 changes: 42 additions & 75 deletions lib/grpmat.gi
Original file line number Diff line number Diff line change
Expand Up @@ -814,78 +814,50 @@ InstallMethod( GroupWithGenerators,
"list of matrices",
[ IsFFECollCollColl ],
#T ???
function( gens )
local G,fam,typ,f,id;
function( gens )
local G,typ,f;

fam:=FamilyObj(gens);
if not IsFinite(gens) then
TryNextMethod();
fi;

typ:=IsGroup and IsAttributeStoringRep
and HasGeneratorsOfMagmaWithInverses
and IsFinitelyGeneratedGroup and HasIsEmpty and IsFinite;

id:=One(gens[1]);
if ForAny(gens,x->x<>id) then
typ:=typ and HasIsTrivial and IsNonTrivial;
if Length(gens)<=1 then
typ:=typ and IsCyclic;
fi;
else
typ:=typ and IsTrivial and HasIsNonTrivial;
fi;

typ:=NewType(fam,typ);
if not IsFinite(gens) then TryNextMethod(); fi;
typ:=MakeGroupyType(FamilyObj(gens),
IsGroup and IsAttributeStoringRep
and HasGeneratorsOfMagmaWithInverses
and IsFinitelyGeneratedGroup and HasIsEmpty and IsFinite,
gens,false,true);

f:=DefaultScalarDomainOfMatrixList(gens);
gens:=List(Immutable(gens),i->ImmutableMatrix(f,i));
f:=DefaultScalarDomainOfMatrixList(gens);
gens:=List(Immutable(gens),i->ImmutableMatrix(f,i));

G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens));
G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens));

if IsField(f) then SetDefaultFieldOfMatrixGroup(G,f);fi;
if IsField(f) then SetDefaultFieldOfMatrixGroup(G,f);fi;

return G;
end );
return G;
end );

InstallMethod( GroupWithGenerators,
"list of matrices with identity", IsCollsElms,
[ IsFFECollCollColl,IsMultiplicativeElementWithInverse and IsFFECollColl],
function( gens, id )
local G,fam,typ,f;
local G,typ,f;

fam:=FamilyObj(gens);
if not IsFinite(gens) then
TryNextMethod();
fi;

typ:=IsGroup and IsAttributeStoringRep
and HasGeneratorsOfMagmaWithInverses
and IsFinitelyGeneratedGroup and HasIsEmpty and IsFinite and HasOne;

if ForAny(gens,x->x<>id) then
typ:=typ and HasIsTrivial and IsNonTrivial;
if Length(gens)<=1 then
typ:=typ and IsCyclic;
fi;
else
typ:=typ and IsTrivial and HasIsNonTrivial;
fi;
if not IsFinite(gens) then TryNextMethod(); fi;
typ:=MakeGroupyType(FamilyObj(gens), IsGroup and IsAttributeStoringRep
and HasGeneratorsOfMagmaWithInverses and IsFinitelyGeneratedGroup
and HasIsEmpty and IsFinite and HasOne,
gens,id,true);

typ:=NewType(fam,typ);
f:=DefaultScalarDomainOfMatrixList(gens);
gens:=List(Immutable(gens),i->ImmutableMatrix(f,i));
id:=ImmutableMatrix(f,id);

f:=DefaultScalarDomainOfMatrixList(gens);
gens:=List(Immutable(gens),i->ImmutableMatrix(f,i));
id:=ImmutableMatrix(f,id);
G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens),
One,id);

G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens),
One,id);
if IsField(f) then SetDefaultFieldOfMatrixGroup(G,f);fi;

if IsField(f) then SetDefaultFieldOfMatrixGroup(G,f);fi;

return G;
return G;
end );

InstallMethod( GroupWithGenerators,
Expand All @@ -894,28 +866,23 @@ InstallMethod( GroupWithGenerators,
function( gens, id )
local G,fam,typ,f;

fam:=FamilyObj([id]);
if not IsFinite(gens) then
TryNextMethod();
fi;

typ:=IsGroup and IsAttributeStoringRep
and HasGeneratorsOfMagmaWithInverses
and IsFinitelyGeneratedGroup and HasIsEmpty and IsFinite and HasOne
and IsTrivial and HasIsNonTrivial;

typ:=NewType(fam,typ);
if not IsFinite(gens) then TryNextMethod(); fi;
typ:=MakeGroupyType(FamilyObj([id]), IsGroup and IsAttributeStoringRep
and HasGeneratorsOfMagmaWithInverses and IsFinitelyGeneratedGroup
and HasIsEmpty and IsFinite and HasOne
and IsTrivial and HasIsNonTrivial,
gens,id,true);

f:=DefaultScalarDomainOfMatrixList([id]);
id:=ImmutableMatrix(f,id);
f:=DefaultScalarDomainOfMatrixList([id]);
id:=ImmutableMatrix(f,id);

G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens),
One,id);
G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens),
One,id);

if IsField(f) then SetDefaultFieldOfMatrixGroup(G,f);fi;
if IsField(f) then SetDefaultFieldOfMatrixGroup(G,f);fi;

return G;
return G;
end );


Expand Down
49 changes: 15 additions & 34 deletions lib/grppc.gi
Original file line number Diff line number Diff line change
Expand Up @@ -353,27 +353,17 @@ local G,fam,typ,id,pcgs;
pcgs:=DefiningPcgs(ElementsFamily(fam));

# pc groups are always finite and gens is finite.
typ:=IsGroup and IsAttributeStoringRep and IsSolvableGroup
and HasIsEmpty and HasGeneratorsOfMagmaWithInverses
and IsFinite and IsFinitelyGeneratedGroup
and HasFamilyPcgs and HasHomePcgs and HasGeneralizedPcgs;

# we can always compare to id cheaply
id:=One(gens[1]);
if ForAny(gens,x->x<>id) then
typ:=typ and HasIsTrivial and IsNonTrivial;
if Length(gens)<=1 then
typ:=typ and IsCyclic;
fi;
else
typ:=typ and IsTrivial and HasIsNonTrivial;
fi;
typ:=NewType(fam,typ);
typ:=MakeGroupyType(fam,
IsGroup and IsAttributeStoringRep and IsSolvableGroup
and HasIsEmpty and HasGeneratorsOfMagmaWithInverses
and IsFinite and IsFinitelyGeneratedGroup
and HasFamilyPcgs and HasHomePcgs and HasGeneralizedPcgs,
gens,One(gens[1]),true);

G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens),
FamilyPcgs,pcgs,HomePcgs,pcgs,GeneralizedPcgs,pcgs);
SetGroupOfPcgs (pcgs, G);
#SetGroupOfPcgs (pcgs, G); That cannot be true, as pcgs is the family pcgs

return G;
end );
Expand All @@ -392,28 +382,19 @@ local G,fam,typ,pcgs;
pcgs:=DefiningPcgs(ElementsFamily(fam));

# pc groups are always finite and gens is finite.
typ:=IsGroup and IsAttributeStoringRep and IsSolvableGroup
and HasIsEmpty and HasGeneratorsOfMagmaWithInverses and HasOne
and IsFinite and IsFinitelyGeneratedGroup
and HasFamilyPcgs and HasHomePcgs and HasGeneralizedPcgs;

# 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;
fi;
else
typ:=typ and IsTrivial and HasIsNonTrivial;
fi;
typ:=NewType(fam,typ);
typ:=MakeGroupyType(fam,
IsGroup and IsAttributeStoringRep and IsSolvableGroup
and HasIsEmpty and HasGeneratorsOfMagmaWithInverses and HasOne
and IsFinite and IsFinitelyGeneratedGroup
and HasFamilyPcgs and HasHomePcgs and HasGeneralizedPcgs,
gens,id,true);

G:=rec();
ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens),
One,id,
FamilyPcgs,pcgs,HomePcgs,pcgs,GeneralizedPcgs,pcgs);

SetGroupOfPcgs (pcgs, G);
#SetGroupOfPcgs (pcgs, G);

return G;
end );
Expand Down Expand Up @@ -446,7 +427,7 @@ local G,fam,typ,pcgs;
One, id,
FamilyPcgs,pcgs,HomePcgs,pcgs,GeneralizedPcgs,pcgs);

SetGroupOfPcgs (pcgs, G);
#SetGroupOfPcgs (pcgs, G);
return G;
end );

Expand Down
Loading

0 comments on commit 425e74d

Please sign in to comment.