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 Jan 12, 2023
1 parent d16a6e2 commit 2f4a518
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 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 @@ -2169,7 +2169,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");

0 comments on commit 2f4a518

Please sign in to comment.