Skip to content

Commit

Permalink
Merge pull request #253 from mohamed-barakat/SingletonMorphismPrecomp…
Browse files Browse the repository at this point in the history
…iled

precompiled SingletonMorphismWithGivenPowerObject to optimal code 🎉
  • Loading branch information
mohamed-barakat authored Mar 7, 2024
2 parents 99c2853 + b27dfb7 commit ab3dc26
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 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.03-01",
Version := "2024.03-02",

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 Expand Up @@ -100,7 +100,7 @@ Dependencies := rec(
NeededOtherPackages := [
[ "CAP", ">= 2023.12-05" ],
[ "CartesianCategories", ">= 2024.02-02" ],
[ "Toposes", ">= 2024.02-02" ],
[ "Toposes", ">= 2024.03-04" ],
],
SuggestedOtherPackages := [ ],
ExternalConditions := [ ],
Expand Down
6 changes: 6 additions & 0 deletions doc/Doc.autodoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
@Subsection Lift
@InsertChunk Lift

@Subsection Singleton morphism
@InsertChunk SingletonMorphism

@Subsection Topos properties
@InsertChunk Topos

Expand Down Expand Up @@ -133,6 +136,9 @@
@Subsection Skeletal Colift
@InsertChunk SkeletalColift

@Subsection Skeletal singleton morphism
@InsertChunk SkeletalSingletonMorphism

@Subsection Skeletal topos properties
@InsertChunk SkeletalTopos

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ list_of_operations :=
"CoimageProjection",
"IsHomSetInhabited",
"TruthMorphismOfImplies",
"SingletonMorphismWithGivenPowerObject",
#"HasPushoutComplement",
"PushoutComplement",
] ) );;
Expand Down
14 changes: 14 additions & 0 deletions examples/SingletonMorphism.g
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! @Chunk SingletonMorphism

#! @Example
LoadPackage( "FinSetsForCAP" );
#! true
a := FinSet( [ 1, 2, 3 ] );
#! <An object in FinSets>
sa := SingletonMorphism( a );
#! <A monomorphism in FinSets>
sa = LowerSegmentOfRelation( a, a, CartesianDiagonal( a, 2 ) );
#! true
sa = UpperSegmentOfRelation( a, a, CartesianDiagonal( a, 2 ) );
#! true
#! @EndExample
15 changes: 15 additions & 0 deletions examples/SkeletalSingletonMorphism.g
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! @Chunk SkeletalSingletonMorphism

#! @Example
LoadPackage( "FinSetsForCAP" );
#! true
a := FinSet( 3 );
#! |3|
sa := SingletonMorphism( a );;
Display( sa );
#! { 0, 1, 2 } ⱶ[ 1, 2, 4 ]→ { 0,..., 7 }
sa = LowerSegmentOfRelation( a, a, CartesianDiagonal( a, 2 ) );
#! true
sa = UpperSegmentOfRelation( a, a, CartesianDiagonal( a, 2 ) );
#! true
#! @EndExample
34 changes: 34 additions & 0 deletions gap/CompilerLogic.gi
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,37 @@ CapJitAddLogicTemplate(
dst_template := "q * GeometricSumDiff1( q, a ) + a * i * GeometricSum( q, a )",
)
);

CapJitAddLogicTemplate(
rec(
variable_names := [ "length", "value", "func" ],
src_template := "List( ListWithIdenticalEntries( length, value ), func )",
dst_template := "ListWithIdenticalEntries( length, func( value ) )",
)
);

CapJitAddLogicTemplate(
rec(
variable_names := [ "length", "value" ],
src_template := "Length( ListWithIdenticalEntries( length, value ) )",
dst_template := "length",
)
);

CapJitAddLogicTemplate(
rec(
variable_names := [ "length", "number" ],
variable_filters := [ IsBigInt, IsBigInt ],
src_template := "Product( ListWithIdenticalEntries( length, number ) )",
dst_template := "number ^ length",
)
);

CapJitAddLogicTemplate(
rec(
variable_names := [ "j", "a", "b" ],
variable_filters := [ IsBigInt, IsBigInt, IsBigInt ],
src_template := "Sum( List( [ 0 .. a - 1 ], k -> List( [ 0 .. a ^ 2 - 1 ], function( x ) if x in List( [ 0 .. a - 1 ], i -> i + i * a ) then return BigInt( 1 ); else return BigInt( 0 ); fi; end )[1 + k + j * a] * b ^ k ) )",
dst_template := "b ^ j",
)
);
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,21 @@ end

, 19464 : IsPrecompiledDerivation := true );

##
AddSingletonMorphismWithGivenPowerObject( cat,

########
function ( cat_1, a_1, Pa_1 )
local hoisted_1_1;
hoisted_1_1 := BigInt( 2 );
return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, Pa_1, AsList, List( [ 0 .. Length( a_1 ) - 1 ], function ( i_2 )
return hoisted_1_1 ^ i_2;
end ) );
end
########

, 605 : IsPrecompiledDerivation := true );

##
AddSomeInjectiveObject( cat,

Expand Down

0 comments on commit ab3dc26

Please sign in to comment.