Skip to content

Commit

Permalink
Merge pull request #266 from mohamed-barakat/CartesianLambdaIntroduction
Browse files Browse the repository at this point in the history
simplify compiled code of CartesianLambdaIntroduction
  • Loading branch information
mohamed-barakat authored Jan 14, 2025
2 parents dc90b84 + 09fe286 commit 75615cb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
2 changes: 1 addition & 1 deletion PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "FinSetsForCAP",
Subtitle := "The elementary topos of (skeletal) finite sets",
Version := "2024.10-02",
Version := "2025.01-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
5 changes: 0 additions & 5 deletions examples/SkeletalCartesianLambdaIntroduction.g
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ Display( Range( lf ) );
#! { 0,..., 7 }
Display( lf );
#! { 0 } ⱶ[ 3 ]→ { 0,..., 7 }
#! #@if ValueOption( "no_precompiled_code" ) <> true
SkeletalFinSets!.cached_precompiled_functions.
CartesianLambdaIntroduction( SkeletalFinSets, f );
#! |1| → |8|
#! #@fi
elf := CartesianLambdaElimination( S, R, lf );
#! |3| → |2|
elf = f;
Expand Down
9 changes: 9 additions & 0 deletions gap/CompilerLogic.gi
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,15 @@ CapJitAddLogicTemplate(
)
);

CapJitAddLogicTemplate(
rec(
variable_names := [ "mor" ],
variable_filters := [ IsMorphismInSkeletalCategoryOfFiniteSets ],
src_template := "List( [ 0 .. Length( Source( mor ) ) - 1 ], i -> AsList( mor )[1 + i] )",
dst_template := "AsList( mor )",
)
);

CapJitAddLogicTemplate(
rec(
variable_names := [ "length", "value", "func" ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,34 +135,13 @@ function ( cat_1, alpha_1 )
deduped_3_1 := Length( Range( alpha_1 ) );
hoisted_1_1 := AsList( alpha_1 );
return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( 1 ) ), CreateCapCategoryObjectWithAttributes( cat_1, Length, deduped_3_1 ^ deduped_4_1 ), AsList, [ Sum( List( [ 0 .. deduped_4_1 - 1 ], function ( k_2 )
return CAP_JIT_INCOMPLETE_LOGIC( hoisted_1_1[(1 + CAP_JIT_INCOMPLETE_LOGIC( k_2 ))] ) * deduped_3_1 ^ k_2;
return hoisted_1_1[(1 + k_2)] * deduped_3_1 ^ k_2;
end ) ) ] );
end
########

, 503 : IsPrecompiledDerivation := true );

##
cat!.cached_precompiled_functions.CartesianLambdaIntroduction :=

########
function ( cat_1, alpha_1 )
local hoisted_1_1, hoisted_2_1, deduped_4_1, deduped_5_1, deduped_6_1;
deduped_6_1 := Length( Source( alpha_1 ) );
deduped_5_1 := Length( Range( alpha_1 ) );
deduped_4_1 := [ 0 .. deduped_6_1 - 1 ];
hoisted_1_1 := AsList( alpha_1 );
hoisted_2_1 := List( deduped_4_1, function ( i_2 )
return hoisted_1_1[1 + i_2];
end );
return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( 1 ) ), CreateCapCategoryObjectWithAttributes( cat_1, Length, deduped_5_1 ^ deduped_6_1 ), AsList, [ Sum( List( deduped_4_1, function ( k_2 )
return hoisted_2_1[(1 + k_2)] * deduped_5_1 ^ k_2;
end ) ) ] );
end
########

;

##
AddCartesianLeftCoevaluationMorphismWithGivenRange( cat,

Expand Down

0 comments on commit 75615cb

Please sign in to comment.