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

Introduce "Target" as an alias of "Range" #1409

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 := "2023.08-03",
Version := "2023.08-04",
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
8 changes: 7 additions & 1 deletion CAP/gap/CategoryMorphisms.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ DeclareAttribute( "Source",
DeclareAttribute( "Range",
IsCapCategoryMorphism );

# this attribute is also an implied operation
#! @Description
#! The argument is a morphism $\alpha: a \rightarrow b$.
#! The output is its target $b$.
#! @Returns an object
#! @Arguments alpha
DeclareAttribute( "Target",
IsCapCategoryMorphism );

###################################
##
Expand Down
5 changes: 5 additions & 0 deletions CAP/gap/CategoryMorphisms.gi
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ InstallValue( PROPAGATION_LIST_FOR_EQUAL_MORPHISMS,
##
######################################

InstallMethod( Target,
[ IsCapCategoryMorphism ],

Range );

InstallMethod( Add,
[ IsCapCategory, IsCapCategoryMorphism ],

Expand Down
8 changes: 8 additions & 0 deletions CAP/gap/CategoryTwoCells.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ DeclareAttribute( "Source",
DeclareAttribute( "Range",
IsCapCategoryTwoCell );

#! @Description
#! The argument is a $2$-cell $c: \alpha \rightarrow \beta$.
#! The output is its target $\beta$.
#! @Returns a morphism
#! @Arguments c
DeclareAttribute( "Target",
IsCapCategoryTwoCell );

###################################
##
## Properties
Expand Down
7 changes: 6 additions & 1 deletion CAP/gap/CategoryTwoCells.gi
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ BindGlobal( "IsCapCategoryTwoCellRep", IsCapCategoryTwoCell );

####################################
##
## Add function
## Operations
##
####################################

InstallMethod( Target,
[ IsCapCategoryTwoCell ],

Range );

##
InstallMethod( Add,
[ IsCapCategory, IsCapCategoryTwoCell ],
Expand Down
2 changes: 1 addition & 1 deletion CompilerForCAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "CompilerForCAP",
Subtitle := "Speed up computations in CAP categories",
Version := "2023.07-01",
Version := "2023.08-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
6 changes: 6 additions & 0 deletions CompilerForCAP/gap/InferDataTypes.gi
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,12 @@

end );

CapJitAddTypeSignature( "Target", [ IsCapCategoryMorphism ], function ( input_types )

return CapJitDataTypeOfObjectOfCategory( input_types[1].category );

Check warning on line 942 in CompilerForCAP/gap/InferDataTypes.gi

View check run for this annotation

Codecov / codecov/patch

CompilerForCAP/gap/InferDataTypes.gi#L942

Added line #L942 was not covered by tests

end );

# GAP operations
CapJitAddTypeSignature( "RETURN_TRUE", [ IsObject, IsObject ], IsBool );
CapJitAddTypeSignature( "Length", [ IsList ], IsInt );
Expand Down
4 changes: 2 additions & 2 deletions CompilerForCAP/gap/Logic.gi
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ CapJitAddLogicFunction( function ( tree )

return object.args.2;

elif attribute_name = "Range" then
elif attribute_name = "Range" or attribute_name = "Target" then

return object.args.3;

Expand Down Expand Up @@ -723,7 +723,7 @@ InstallGlobalFunction( CAP_JIT_INTERNAL_TELESCOPED_ITERATION, function ( tree, r
# Source can be recovered from initial_value
CapJitIsCallToGlobalFunction( source, "Source" ) and source.args.length = 1 and source.args.1.type = "EXPR_REF_FVAR" and source.args.1.func_id = result_func.id and source.args.1.name = result_func.nams[1] and
# Range can be recovered from initial_value
CapJitIsCallToGlobalFunction( range, "Range" ) and range.args.length = 1 and range.args.1.type = "EXPR_REF_FVAR" and range.args.1.func_id = result_func.id and range.args.1.name = result_func.nams[1]
CapJitIsCallToGlobalFunction( range, gvar -> gvar in [ "Range", "Target" ] ) and range.args.length = 1 and range.args.1.type = "EXPR_REF_FVAR" and range.args.1.func_id = result_func.id and range.args.1.name = result_func.nams[1]
then

case := "from_initial_value";
Expand Down
20 changes: 18 additions & 2 deletions CompilerForCAP/gap/LogicTemplates.gi
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,16 @@

fi;

if template_tree.funcref.type = "EXPR_REF_GVAR" and not IsIdenticalObj( ValueGlobal( tree.funcref.gvar ), ValueGlobal( template_tree.funcref.gvar ) ) then
if template_tree.funcref.type = "EXPR_REF_GVAR" then

return fail;
if
not IsIdenticalObj( ValueGlobal( tree.funcref.gvar ), ValueGlobal( template_tree.funcref.gvar ) ) and
not (template_tree.funcref.gvar in [ "Range", "Target" ] and tree.funcref.gvar in [ "Range", "Target" ] and IsBound( tree.funcref.data_type ) and IsSpecializationOfFilter( IsCapCategoryMorphism, tree.funcref.data_type.signature[1][1].filter ))
then

return fail;

fi;

fi;

Expand Down Expand Up @@ -651,6 +658,15 @@

continue;

elif template_tree.gvar in [ "Range", "Target" ] and tree.gvar in [ "Range", "Target" ] and IsBound( tree.data_type ) and IsSpecializationOfFilter( IsCapCategoryMorphism, tree.data_type.signature[1][1].filter ) then

if debug then

Check warning on line 663 in CompilerForCAP/gap/LogicTemplates.gi

View check run for this annotation

Codecov / codecov/patch

CompilerForCAP/gap/LogicTemplates.gi#L663

Added line #L663 was not covered by tests
# COVERAGE_IGNORE_NEXT_LINE
Display( "match: gvars are both Range resp. Target of a morphism" );
fi;

Check warning on line 666 in CompilerForCAP/gap/LogicTemplates.gi

View check run for this annotation

Codecov / codecov/patch

CompilerForCAP/gap/LogicTemplates.gi#L666

Added line #L666 was not covered by tests

continue;

Check warning on line 668 in CompilerForCAP/gap/LogicTemplates.gi

View check run for this annotation

Codecov / codecov/patch

CompilerForCAP/gap/LogicTemplates.gi#L668

Added line #L668 was not covered by tests

else

if debug then
Expand Down