Skip to content

Commit

Permalink
forbid implications from non-representations to representations
Browse files Browse the repository at this point in the history
Filters of type representation are intended to describe
the internal data of an object.
Thus a logical implication to such a filter makes sense only
if the implying filters are also representations.

As had be noticed by fingolfin,
there was a now forbidden hidden implication in the library,
from `IsHandledByNiceBasis` to `IsAttributeStoringRep`.
Logically, one wants this rather the other way round,
that is, the mechanism relies on stored data and thus should be *restricted*
to situations where `IsAttributeStoringRep` is present.
I have now changed this setup accordingly, that is,
`IsAttributeStoringRep` is no longer implied by `IsHandledByNiceBasis`.
As a consequence, one `Objectify` call in the library had to be changed
such that `IsAttributeStoringRep` gets explicitly set.

(The same might happen also in packages.)
  • Loading branch information
ThomasBreuer authored and fingolfin committed Dec 31, 2021
1 parent 8e6c540 commit 1693496
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
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
15 changes: 15 additions & 0 deletions lib/filter.g
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,21 @@ end);
##

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

# Check whether 'tofilt' involves or implies representations.
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' consists of representations.
for i in TRUES_FLAGS( WITH_IMPS_FLAGS( FLAGS_FILTER( from ) ) ) do
if not ( INFO_FILTERS[i] = FNUM_REP_KERN or
INFO_FILTERS[i] = FNUM_REP ) then
Error( "<tofilt> must not involve representation filters" );
fi;
od;
break;
fi;
od;

InstallTrueMethodNewFilter( tofilt, from );

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
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
9 changes: 9 additions & 0 deletions tst/testinstall/method.tst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ 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> InstallTrueMethod( IsInternalRep, IsList );
Error, <tofilt> must not involve representation filters
gap> InstallTrueMethod( IsDenseCoeffVectorRep, IsList );
Error, <tofilt> must not involve representation filters
gap> InstallTrueMethod( IsInternalRep, IsSmallIntRep );

#
gap> STOP_TEST("method.tst", 1);

0 comments on commit 1693496

Please sign in to comment.