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

Better keep track of the type of operations added to a category #1696

Merged
merged 10 commits into from
Oct 7, 2024
2 changes: 1 addition & 1 deletion CAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "CAP",
Subtitle := "Categories, Algorithms, Programming",
Version := "2024.09-29",
Version := "2024.10-01",
Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ),
License := "GPL-2.0-or-later",

Expand Down
10 changes: 10 additions & 0 deletions CAP/gap/CAP.gd
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,16 @@ DeclareOperation( "CanCompute",
[ IsCapCategory, IsFunction ] );
#! @EndGroup

#! @Description
#! Returns the weight of the operation currently installed as <A>op_name</A> in <A>cat</A>.
#! @Returns an integer
#! @Arguments cat, op_name
DeclareOperation( "OperationWeight",
[ IsCapCategory, IsString ] );

DeclareGlobalFunction( "ListInstalledOperationsOfCategory" );
DeclareGlobalFunction( "ListPrimitivelyInstalledOperationsOfCategory" );

#! @Description
#! The arguments are a category $C$ and a string $s$.
#! If $s$ is a categorical property (e.g. <C>"IsAbelianCategory"</C>),
Expand Down
72 changes: 67 additions & 5 deletions CAP/gap/CAP.gi
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@

od;

obj!.primitive_operations := rec( );

obj!.added_functions := rec( );

obj!.operations := rec( );

obj!.timing_statistics := rec( );
obj!.timing_statistics_enabled := false;

Expand Down Expand Up @@ -599,9 +599,7 @@

fi;

weight_list := category!.derivations_weight_list;

return CurrentOperationWeight( weight_list, string ) <> infinity;
return IsBound( category!.operations.(string) );

end );

Expand All @@ -617,6 +615,70 @@

end );

##
InstallMethod( OperationWeight,
[ IsCapCategory, IsString ],

function( category, op_name )

return category!.operations.(op_name).weight;

end );

##
InstallGlobalFunction( ListInstalledOperationsOfCategory,

function( arg )
local cat, filter, names;

if Length( arg ) < 1 then
Error( "first argument needs to be <category>" );

Check warning on line 635 in CAP/gap/CAP.gi

View check run for this annotation

Codecov / codecov/patch

CAP/gap/CAP.gi#L635

Added line #L635 was not covered by tests
fi;

cat := arg[ 1 ];

if Length( arg ) > 1 then
filter := arg[ 2 ];

Check warning on line 641 in CAP/gap/CAP.gi

View check run for this annotation

Codecov / codecov/patch

CAP/gap/CAP.gi#L641

Added line #L641 was not covered by tests
else
filter := fail;
fi;

if IsCapCategoryCell( cat ) then
cat := CapCategory( cat );

Check warning on line 647 in CAP/gap/CAP.gi

View check run for this annotation

Codecov / codecov/patch

CAP/gap/CAP.gi#L647

Added line #L647 was not covered by tests
fi;

if not IsCapCategory( cat ) then
Error( "input is not a category (cell)" );

Check warning on line 651 in CAP/gap/CAP.gi

View check run for this annotation

Codecov / codecov/patch

CAP/gap/CAP.gi#L651

Added line #L651 was not covered by tests
fi;

names := RecNames( cat!.operations );

if filter <> fail then
names := Filtered( names, i -> PositionSublist( i, filter ) <> fail );

Check warning on line 657 in CAP/gap/CAP.gi

View check run for this annotation

Codecov / codecov/patch

CAP/gap/CAP.gi#L657

Added line #L657 was not covered by tests
fi;

return AsSortedList( names );

end );

##
InstallGlobalFunction( ListPrimitivelyInstalledOperationsOfCategory,

function( arg )
local cat, names;

if Length( arg ) < 1 then
Error( "first argument needs to be <category>" );

Check warning on line 671 in CAP/gap/CAP.gi

View check run for this annotation

Codecov / codecov/patch

CAP/gap/CAP.gi#L671

Added line #L671 was not covered by tests
fi;

cat := arg[ 1 ];

names := CallFuncList( ListInstalledOperationsOfCategory, arg );

return Filtered( names, x -> cat!.operations.(x).type = "primitive_installation" );

end );

##
InstallMethod( MissingOperationsForConstructivenessOfCategory,
[ IsCapCategory, IsString ],
Expand Down
32 changes: 23 additions & 9 deletions CAP/gap/Derivations.gd
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ DeclareOperation( "OperationWeightUsingDerivation",
DeclareOperation( "DerivationOfOperation", [ IsOperationWeightList, IsString ] );

#! @Description
#! Performs a search from the operation <A>op_name</A>, and installs all derivations
#! Performs a search from the operation <A>op_name</A>, and triggers all derivations
#! that give improvements over the current state.
#! This is used internally by <C>AddPrimitiveOperation</C> and <C>Reevaluate</C>.
#! This is used internally by <C>TriggerAllDerivations</C> and <C>Reevaluate</C>.
#! It should normally not be necessary to call this function directly.
#! @Arguments owl, op_name
DeclareOperation( "InstallDerivationsUsingOperation",
DeclareOperation( "TriggerDerivationsUsingOperation",
[ IsOperationWeightList, IsString ] );

#! @Description
Expand All @@ -264,9 +264,6 @@ DeclareOperation( "Saturate", [ IsOperationWeightList ] );
#! @Description
#! Add the operation named <A>op_name</A> to the operation weight list <A>owl</A>
#! with weight <A>weight</A>.
#! This causes all operations that can be derived, directly or indirectly,
#! from the newly added operation to be installed as well
#! (unless they are already installed with the same or lower weight).
#! @Arguments owl, op_name, weight
DeclareOperation( "AddPrimitiveOperation", [ IsOperationWeightList, IsString, IsInt ] );

Expand All @@ -283,6 +280,26 @@ DeclareOperation( "PrintTree", [ IsObject, IsFunction, IsFunction ] );
DeclareOperation( "PrintTreeRec",
[ IsObject, IsFunction, IsFunction, IsInt ] );

#################################
##
## Final derivations
##
#################################

DeclareGlobalVariable( "CAP_INTERNAL_FINAL_DERIVATION_LIST" );

DeclareGlobalFunction( "AddFinalDerivation" );

DeclareGlobalFunction( "AddFinalDerivationBundle" );

#################################
##
## Triggering derivations
##
#################################

DeclareGlobalFunction( "TriggerAllDerivations" );

#################################
##
## Some print functions
Expand All @@ -291,6 +308,3 @@ DeclareOperation( "PrintTreeRec",

DeclareGlobalFunction( "InstalledMethodsOfCategory" );
DeclareGlobalFunction( "DerivationsOfMethodByCategory" );

DeclareGlobalFunction( "ListInstalledOperationsOfCategory" );
DeclareGlobalFunction( "ListPrimitivelyInstalledOperationsOfCategory" );
Loading
Loading