From d8701259b219cf93212e4b7483727b33d177f87c Mon Sep 17 00:00:00 2001 From: ThomasBreuer Date: Tue, 20 Dec 2022 17:43:09 +0100 Subject: [PATCH] adjust to the discussion allow implications to representations that are already implied --- lib/filter.g | 28 +++++++++++++++------------- tst/testinstall/method.tst | 7 ++++--- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/filter.g b/lib/filter.g index f318617f90..83b182a168 100644 --- a/lib/filter.g +++ b/lib/filter.g @@ -285,29 +285,32 @@ end); ## Adding logical implications can change the rank of filters (see ## ) and consequently the rank, and so choice of ## methods for operations (see ). -## By default InstallTrueMethod adjusts the method selection data -## structures to take care of this, but this process can be time-consuming, +## By default adjusts the method selection +## data structures to take care of this, +## but this process can be time-consuming, ## so functions and ## are provided to allow control of this process. ## ## ## <#/GAPDoc> ## - BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from ) - local i; + local fromflags, i, j; # 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' 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( " must not involve representation filters" ); - fi; - od; - break; + # This is allowed only if either 'from' already implies filter 'i' + # or if 'from' consists of representations. + if not i in fromflags then + for j in fromflags do + if not ( INFO_FILTERS[j] = FNUM_REP_KERN or + INFO_FILTERS[j] = FNUM_REP ) then + Error( " must not involve new representation filters" ); + fi; + od; + fi; fi; od; @@ -321,7 +324,6 @@ BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from ) if REORDER_METHODS_SUSPENSION_LEVEL = 0 then RECALCULATE_ALL_METHOD_RANKS(); fi; - end ); diff --git a/tst/testinstall/method.tst b/tst/testinstall/method.tst index 4e0cf0d796..671eed301f 100644 --- a/tst/testinstall/method.tst +++ b/tst/testinstall/method.tst @@ -10,8 +10,9 @@ Error, required filters [ "IsInt", "IsRat", "IsCyc", "IsExtAElement", "IsAdditivelyCommutativeElement", "IsCommutativeElement", "IsCyclotomic" ] for 1st argument do not match a declaration of Size gap> InstallTrueMethod( IsInternalRep, IsList ); -Error, must not involve representation filters +Error, must not involve new representation filters gap> InstallTrueMethod( IsDenseCoeffVectorRep, IsList ); -Error, must not involve representation filters +Error, must not involve new representation filters gap> InstallTrueMethod( IsInternalRep, IsSmallIntRep ); -gap> STOP_TEST("method.tst", 1); +gap> InstallTrueMethod( IsList and IsInternalRep, IsList and IsSmallIntRep ); +gap> STOP_TEST("method.tst");