Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid installing new implications to representations using InstallTrueMethod #3006

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/basis.gi
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,14 @@ InstallGlobalFunction( "InstallHandlingByNiceBasis",
filter:= ValueGlobal( name );

# Install the detection of the filter.
# The mechanism is safe only if the domain can store
# its nice variant, thus we will install it only for cases where
# 'IsAttributeStoringRep' is guaranteed.
entry:= First( NiceBasisFiltersInfo,
x -> IsIdenticalObj( filter, x[1] ) );
entry[3] := record.detect;
filter:= filter and IsFreeLeftModule and IsAttributeStoringRep;
InstallTrueMethod( IsHandledByNiceBasis, filter );
filter:= IsFreeLeftModule and filter;

# Install the methods.
InstallMethod( NiceFreeLeftModuleInfo,
Expand Down
19 changes: 15 additions & 4 deletions lib/filter.g
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,28 @@ end);
## Adding logical implications can change the rank of filters (see
## <Ref Func="RankFilter"/>) and consequently the rank, and so choice of
## methods for operations (see <Ref Sect="Applicable Methods and Method Selection"/>).
## By default <C>InstallTrueMethod</C> adjusts the method selection data
## structures to take care of this, but this process can be time-consuming,
## By default <Ref Func="InstallTrueMethod"/> adjusts the method selection
## data structures to take care of this,
## but this process can be time-consuming,
## so functions <Ref Func="SuspendMethodReordering"/> and
## <Ref Func="ResumeMethodReordering"/> are provided to allow control of this process.
## </Description>
## </ManSection>
## <#/GAPDoc>
##

BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from )
local fromflags, i;

# Check whether 'tofilt' involves or implies representations.
fromflags:= TRUES_FLAGS( WITH_IMPS_FLAGS( FLAGS_FILTER( from ) ) );
for i in TRUES_FLAGS( WITH_IMPS_FLAGS( FLAGS_FILTER( tofilt ) ) ) do
if INFO_FILTERS[i] = FNUM_REP_KERN or INFO_FILTERS[i] = FNUM_REP then
# This is allowed only if 'from' already implies filter 'i'.
if not i in fromflags then
Error( "<tofilt> must not involve new representation filters" );
fi;
fi;
od;

InstallTrueMethodNewFilter( tofilt, from );

Expand All @@ -305,7 +317,6 @@ BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from )
if REORDER_METHODS_SUSPENSION_LEVEL = 0 then
RECALCULATE_ALL_METHOD_RANKS();
fi;

end );


Expand Down
4 changes: 1 addition & 3 deletions lib/module.gd
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ DeclareProperty( "IsFullMatrixModule", IsFreeLeftModule, 20 );
## </ManSection>
## <#/GAPDoc>
##
DeclareCategory( "IsHandledByNiceBasis",
IsFreeLeftModule and IsAttributeStoringRep );
#T individually choose for each repres. in this category?
DeclareCategory( "IsHandledByNiceBasis", IsFreeLeftModule );
#T why not `DeclareFilter' ?


Expand Down
4 changes: 3 additions & 1 deletion lib/type.g
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ BIND_GLOBAL( "DeclareRepresentationKernel", function ( name, super, rep )
od;

od;
InstallTrueMethod( super, rep );

# Calling 'InstallTrueMethod' for two representations is not allowed.
InstallTrueMethodNewFilter( super, rep );
BIND_GLOBAL( name, rep );
SET_NAME_FUNC( rep, name );
end );
Expand Down
3 changes: 2 additions & 1 deletion lib/vspchom.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,8 @@ InstallMethod( Hom,
IsFreeLeftModule
and IsFullHomModule
and IsLinearMappingsModule
and IsGeneralMappingCollection ),
and IsGeneralMappingCollection
and IsAttributeStoringRep ),
rec() );

SetLeftActingDomain( M, F );
Expand Down
8 changes: 7 additions & 1 deletion tst/testinstall/method.tst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Error, required filters [ "IsInt", "IsRat", "IsCyc", "IsExtAElement",
, "IsMultiplicativeElementWithInverse", "IsZDFRE", "IsAssociativeElement",
"IsAdditivelyCommutativeElement", "IsCommutativeElement", "IsCyclotomic" ]
for 1st argument do not match a declaration of Size
gap> InstallTrueMethod( IsInternalRep, IsList );
Error, <tofilt> must not involve new representation filters
gap> InstallTrueMethod( IsDenseCoeffVectorRep, IsList );
Error, <tofilt> must not involve new representation filters
gap> InstallTrueMethod( IsInternalRep, IsSmallIntRep );
gap> InstallTrueMethod( IsList and IsInternalRep, IsList and IsSmallIntRep );

# Check names are set correctly
gap> cheese := NewOperation("cheese", [IsObject]);
Expand All @@ -27,4 +33,4 @@ gap> List(Concatenation(funcs, ranks), NameFunction);
[ "cheese method", "cheese for a list", "func3",
"Priority calculation for cheese",
"Priority calculation for cheese for a list", "rank3" ]
gap> STOP_TEST("method.tst", 1);
gap> STOP_TEST("method.tst");