Skip to content

Commit

Permalink
Merge pull request #1696 from zickgraf/master
Browse files Browse the repository at this point in the history
Better keep track of the type of operations added to a category
  • Loading branch information
zickgraf authored Oct 7, 2024
2 parents 1cc62b1 + 88eef97 commit 18a3d2a
Show file tree
Hide file tree
Showing 16 changed files with 611 additions and 570 deletions.
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 @@ InstallGlobalFunction( "CreateCapCategoryWithDataTypes", FunctionWithNamedArgume

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 @@ InstallMethod( CanCompute,

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 @@ InstallMethod( CanCompute,

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>" );
fi;

cat := arg[ 1 ];

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

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

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

names := RecNames( cat!.operations );

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

return AsSortedList( names );

end );

##
InstallGlobalFunction( ListPrimitivelyInstalledOperationsOfCategory,

function( arg )
local cat, names;

if Length( arg ) < 1 then
Error( "first argument needs to be <category>" );
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

0 comments on commit 18a3d2a

Please sign in to comment.