Skip to content
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 ModulePresentationsForCAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "ModulePresentationsForCAP",
Subtitle := "Category R-pres for CAP",
Version := "2024.09-02",
Version := "2025.06-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
153 changes: 35 additions & 118 deletions ModulePresentationsForCAP/gap/ModulePresentationsForCAP.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ InstallGlobalFunction( ADD_COEVALUATION_MORPHISM_RIGHT,

end );

InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,
InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,

function( category )
local homalg_ring, lift_via_compiled_linear_system_func, colift_via_compiled_linear_system_func;
Expand Down Expand Up @@ -1088,20 +1088,11 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,
M := UnderlyingMatrix( Source( morphism_2 ) );

v := NrColumns( M );

s := NrColumns( P );

N := UnderlyingMatrix( Range( morphism_1 ) );

# NrColumns( N ) = 0 implies coker(N)=0 and s = 0 implies coker(P)=0, hence morphism_1 is zero, and the zero morphism can always be lifted.
if NrColumns( N ) = 0 or s = 0 then
return ZeroMorphism( Source( morphism_1 ), Source( morphism_2 ) );
fi;

# if NrColumns(M)=0 then M is zero, hence lift exists iff morphism_1 is zero.
if NrColumns( M ) = 0 and IsZeroForMorphisms( morphism_1 ) then
return ZeroMorphism( Source( morphism_1 ), Source( morphism_2 ) );
fi;
A := UnderlyingMatrix( morphism_1 );

B := UnderlyingMatrix( morphism_2 );
Expand All @@ -1110,31 +1101,23 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,

N_tr_I := KroneckerMat( TransposedMatrix( N ), HomalgIdentityMatrix( NrColumns( P ) ,homalg_ring ) );

zero_1 := HomalgZeroMatrix( NrRows( A )*NrColumns( A ), NrRows( P )*NrRows( M ), homalg_ring );
zero_1 := HomalgZeroMatrix( NrRows( A ) * NrColumns( A ), NrRows( P ) * NrRows( M ), homalg_ring );

mat1 := UnionOfColumns( B_tr_I, N_tr_I, zero_1 );

I_P := KroneckerMat( HomalgIdentityMatrix( NrColumns( M ) ,homalg_ring ), P );

zero_2 := HomalgZeroMatrix( NrRows( P )*NrColumns( M ), NrRows( A )*NrRows( N ), homalg_ring );
zero_2 := HomalgZeroMatrix( NrRows( P ) * NrColumns( M ), NrRows( A ) * NrRows( N ), homalg_ring );

M_tr_I := KroneckerMat( TransposedMatrix( M ), HomalgIdentityMatrix( NrRows( P ) ,homalg_ring ) );
M_tr_I := KroneckerMat( TransposedMatrix( M ), HomalgIdentityMatrix( NrRows( P ), homalg_ring ) );

mat2 := UnionOfColumns( I_P, zero_2, M_tr_I );

mat := UnionOfRows( mat1, mat2 );

if NrColumns( A ) <= 1 then

vec_A := A;

else

vec_A := UnionOfRows( List( [ 1 .. NrColumns( A ) ], i-> CertainColumns( A, [ i ] ) ) );

fi;
vec_A := ConvertMatrixToColumn( A );

vec_zero := HomalgZeroMatrix( NrRows( P )*NrColumns( M ), 1, homalg_ring );
vec_zero := HomalgZeroMatrix( NrRows( P ) * NrColumns( M ), NrColumns( vec_A ), homalg_ring );

vec := UnionOfRows( vec_A, vec_zero );

Expand All @@ -1155,11 +1138,7 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,

sol := CallFuncList( LeftDivide, lift_via_compiled_linear_system_func( morphism_1, morphism_2 ) );

if v <= 1 then
XX := CertainRows( sol, [ 1.. s ] );
else
XX := UnionOfColumns( List( [ 1 .. v ], i-> CertainRows( sol, [ (i-1)*s+1.. i*s ] ) ) );
fi;
XX := ConvertColumnToMatrix( CertainRows( sol, [ 1 .. s * v ] ), s, v );

return PresentationMorphism( cat, Source( morphism_1 ), XX, Source( morphism_2 ) );

Expand Down Expand Up @@ -1195,21 +1174,11 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,
M := UnderlyingMatrix( Range( morphism_1 ) );

v := NrColumns( M );

s := NrColumns( I );

N := UnderlyingMatrix( Source( morphism_1 ) );

# NrColumns( N ) = 0 implies coker(N)=0 and s = 0 implies coker(I)=0, hence morphism_2 is zero, and the zero morphism can always be colifted.
if NrColumns( N ) = 0 or s = 0 then
return ZeroMorphism( Range( morphism_1 ), Range( morphism_2 ) );
fi;

# if NrColumns(M)=0 then M is zero, hence colift exists iff morphism_2 is zero.
if NrColumns( M ) = 0 and IsZeroForMorphisms( morphism_2 ) then
return ZeroMorphism( Range( morphism_1 ), Range( morphism_2 ) );
fi;

B := UnderlyingMatrix( morphism_1 );

A := UnderlyingMatrix( morphism_2 );
Expand All @@ -1226,12 +1195,8 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,

A_over_zero := UnionOfRows( A, zero_mat );

if NrColumns( A ) <= 1 then
vec := A_over_zero;
else
vec := UnionOfRows( List( [ 1 .. NrColumns( A ) ], i-> CertainColumns( A_over_zero, [ i ] ) ) );
fi;

vec := ConvertMatrixToColumn( A_over_zero );

return [ mat, vec ];

end;
Expand All @@ -1249,15 +1214,7 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,

sol := CallFuncList( LeftDivide, colift_via_compiled_linear_system_func( morphism_1, morphism_2 ) );

v := NrColumns( M );

s := NrColumns( I );

if s <= 1 then
XX := CertainRows( sol, [ 1.. v ] );
else
XX := UnionOfColumns( List( [ 1 .. s ], i-> CertainRows( sol, [ (i-1)*v+1.. i*v ] ) ) );
fi;
XX := ConvertColumnToMatrix( CertainRows( sol, [ 1 .. v * s ] ), v, s );

return PresentationMorphism( cat, Range( morphism_1 ), XX, Range( morphism_2 ) );

Expand All @@ -1272,21 +1229,21 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,
end );

##
InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,

function( category )
local homalg_ring, lift_via_compiled_linear_system_func, colift_via_compiled_linear_system_func;

homalg_ring := category!.ring_for_representation_category;

lift_via_compiled_linear_system_func := function( morphism_1, morphism_2 )
local Pt, Nt, Mt, At, Bt, B_tr_I, N_tr_I, zero_1,
local Pt, Nt, Mt, At, Bt, B_tr_I, N_tr_I, zero_1,
mat1, mat2, I_P, zero_2, M_tr_I, mat, vec_A, vec_zero, vec, v, s;
# rxs
# P
# |
# uxr | mxr
# X (A)
# uxr | mxr
# X (A)
# |
# V
# uxv mxu mxn
Expand All @@ -1296,10 +1253,10 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
# We need to solve the system
# B*X = A mod N
# X*P + M*Y = 0
# I.e., looking for X, Y, Z such that
# I.e., looking for X, Y, Z such that
# B*X + N*Y = A
# X*P + M*Z = 0
# which is equivalent to
# which is equivalent to
# XX*B^t + YY*N^t = A^t
# P^t*XX + ZZ*M^t = 0
# which can be solved exactly as Lift in left presentations case.
Expand All @@ -1314,47 +1271,31 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,

Nt := TransposedMatrix( UnderlyingMatrix( Range( morphism_1 ) ) );

if NrRows( Nt ) = 0 or s = 0 then
return ZeroMorphism( Source( morphism_1 ), Source( morphism_2 ) );
fi;

if NrRows( Mt ) = 0 and IsZeroForMorphisms( morphism_1 ) then
return ZeroMorphism( Source( morphism_1 ), Source( morphism_2 ) );
fi;

At := TransposedMatrix( UnderlyingMatrix( morphism_1 ) );

Bt := TransposedMatrix( UnderlyingMatrix( morphism_2 ) );

B_tr_I := KroneckerMat( TransposedMatrix( Bt ), HomalgIdentityMatrix( NrColumns( Pt ), homalg_ring ) );

N_tr_I := KroneckerMat( TransposedMatrix( Nt ), HomalgIdentityMatrix( NrColumns( Pt ) ,homalg_ring ) );
N_tr_I := KroneckerMat( TransposedMatrix( Nt ), HomalgIdentityMatrix( NrColumns( Pt ), homalg_ring ) );

zero_1 := HomalgZeroMatrix( NrRows( At )*NrColumns( At ), NrRows( Pt )*NrRows( Mt ), homalg_ring );
zero_1 := HomalgZeroMatrix( NrRows( At ) * NrColumns( At ), NrRows( Pt ) * NrRows( Mt ), homalg_ring );

mat1 := UnionOfColumns( B_tr_I, N_tr_I, zero_1 );

I_P := KroneckerMat( HomalgIdentityMatrix( NrColumns( Mt ) ,homalg_ring ), Pt );
I_P := KroneckerMat( HomalgIdentityMatrix( NrColumns( Mt ), homalg_ring ), Pt );

zero_2 := HomalgZeroMatrix( NrRows( Pt )*NrColumns( Mt ), NrRows( At )*NrRows( Nt ), homalg_ring );
zero_2 := HomalgZeroMatrix( NrRows( Pt ) * NrColumns( Mt ), NrRows( At ) * NrRows( Nt ), homalg_ring );

M_tr_I := KroneckerMat( TransposedMatrix( Mt ), HomalgIdentityMatrix( NrRows( Pt ) ,homalg_ring ) );
M_tr_I := KroneckerMat( TransposedMatrix( Mt ), HomalgIdentityMatrix( NrRows( Pt ), homalg_ring ) );

mat2 := UnionOfColumns( I_P, zero_2, M_tr_I );

mat := UnionOfRows( mat1, mat2 );

if NrColumns( At ) <= 1 then

vec_A := At;

else

vec_A := UnionOfRows( List( [ 1 .. NrColumns( At ) ], i-> CertainColumns( At, [ i ] ) ) );

fi;
vec_A := ConvertMatrixToColumn( At );

vec_zero := HomalgZeroMatrix( NrRows( Pt )*NrColumns( Mt ), 1, homalg_ring );
vec_zero := HomalgZeroMatrix( NrRows( Pt ) * NrColumns( Mt ), NrColumns( vec_A ), homalg_ring );

vec := UnionOfRows( vec_A, vec_zero );

Expand All @@ -1363,7 +1304,7 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
end;

AddLift( category, function( cat, morphism_1, morphism_2 )
local Pt, Mt, v, s, sol, XX;
local Pt, Mt, v, s, sol, XX_tr;

Pt := TransposedMatrix( UnderlyingMatrix( Source( morphism_1 ) ) );
Mt := TransposedMatrix( UnderlyingMatrix( Source( morphism_2 ) ) );
Expand All @@ -1374,13 +1315,9 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,

sol := CallFuncList( LeftDivide, lift_via_compiled_linear_system_func( morphism_1, morphism_2 ) );

if v <= 1 then
XX := TransposedMatrix( CertainRows( sol, [ 1.. s ] ) );
else
XX := TransposedMatrix( UnionOfColumns( List( [ 1 .. v ], i-> CertainRows( sol, [ (i-1)*s+1.. i*s ] ) ) ) );
fi;
XX_tr := ConvertColumnToMatrix( CertainRows( sol, [ 1 .. s * v ] ), s, v );

return PresentationMorphism( cat, Source( morphism_1 ), XX, Source( morphism_2 ) );
return PresentationMorphism( cat, Source( morphism_1 ), TransposedMatrix( XX_tr ), Source( morphism_2 ) );

end );

Expand All @@ -1398,19 +1335,11 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
Mt := TransposedMatrix( UnderlyingMatrix( Range( morphism_1 ) ) );

v := NrColumns( Mt );

s := NrColumns( It );

Nt := TransposedMatrix( UnderlyingMatrix( Source( morphism_1 ) ) );

if NrRows( Nt ) = 0 or s = 0 then
return ZeroMorphism( Range( morphism_1 ), Range( morphism_2 ) );
fi;
Nt := TransposedMatrix( UnderlyingMatrix( Source( morphism_1 ) ) );

if NrRows( Mt ) = 0 and IsZeroForMorphisms( morphism_2 ) then
return ZeroMorphism( Range( morphism_1 ), Range( morphism_2 ) );
fi;

Bt := TransposedMatrix( UnderlyingMatrix( morphism_1 ) );

At := TransposedMatrix( UnderlyingMatrix( morphism_2 ) );
Expand All @@ -1427,18 +1356,14 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,

A_over_zero := UnionOfRows( At, zero_mat );

if NrColumns( At ) <= 1 then
vec := A_over_zero;
else
vec := UnionOfRows( List( [ 1 .. NrColumns( At ) ], i-> CertainColumns( A_over_zero, [ i ] ) ) );
fi;

vec := ConvertMatrixToColumn( A_over_zero );

return [ mat, vec ];

end;

AddColift( category, function( cat, morphism_1, morphism_2 )
local It, Mt, v, s, sol, XX;
local It, Mt, v, s, sol, XX_tr;

It := TransposedMatrix( UnderlyingMatrix( Range( morphism_2 ) ) );

Expand All @@ -1450,17 +1375,9 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,

sol := CallFuncList( LeftDivide, colift_via_compiled_linear_system_func( morphism_1, morphism_2 ) );

v := NrColumns( Mt );

s := NrColumns( It );

if s <= 1 then
XX := TransposedMatrix( CertainRows( sol, [ 1.. v ] ) );
else
XX := TransposedMatrix( UnionOfColumns( List( [ 1 .. s ], i-> CertainRows( sol, [ (i-1)*v+1.. i*v ] ) ) ) );
fi;
XX_tr := ConvertColumnToMatrix( CertainRows( sol, [ 1 .. v * s ] ), v, s );

return PresentationMorphism( cat, Range( morphism_1 ), XX, Range( morphism_2 ) );
return PresentationMorphism( cat, Range( morphism_1 ), TransposedMatrix( XX_tr ), Range( morphism_2 ) );

end, 1000 );

Expand Down
32 changes: 32 additions & 0 deletions ModulePresentationsForCAP/tst/Lift_Colift.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
gap> START_TEST( "Lift/Colift" );

gap> LoadPackage( "ModulePresentationsForCAP", false );
true

gap> LoadPackage( "RingsForHomalg", false );
true

gap> Qx := HomalgFieldOfRationalsInSingular() * "x";;
gap> Qx_lpres := LeftPresentations( Qx );;
gap> M_mat := HomalgMatrix( "[ [ 31*x^2, 34*x^2+11*x+32, 0, 0, 42*x ], [ 0, 0, 0, 0, 0 ] ]", 2, 5, Qx );;
gap> M := AsLeftPresentation( M_mat );;
gap> N_mat := HomalgMatrix( "[ [ 0, 0, 0, 0, 128954616*x^3+941617341*x^2+907117596*x+56921403, 39256140*x^3+41218947*x^2, 72623859*x^2+69844593*x+907117596, 70661052, 37293333*x^3+25516491*x, 98140350*x^3+69688290*x^2+561548988*x ], [ 0, 39*x, 38*x^3, 18*x^3+38*x^2, 0, 0, 48*x^3+37*x, 0, 0, 8*x^2 ], [ 0, 0, 0, 0, -580852608*x^3-1254907101*x^2-827402436*x-141045009, -97272420*x^3-102136041*x^2, -179953977*x^2-447450297*x-827402436, -175090356, -92408799*x^3-63227073*x, -243181050*x^3-342536124*x^2-512201508*x ] ]", 3, 10, Qx );;
gap> N := AsLeftPresentation( N_mat );;
gap> P_mat := HomalgMatrix( "[ [ 0, 0, 714*x-3696, 0 ] ]", 1, 4, Qx );;
gap> P := AsLeftPresentation( P_mat );;
gap> f_mat := HomalgMatrix( "[ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 166751424*x^5+94916052*x^4-127178772*x^3-42880992*x^2+13268892*x, 69479760*x^5+82104708*x^4+9608508*x^3, 128537556*x^4+75987072*x^3+7778316*x^2-143626644*x, 125063568*x^2+16471728*x, 66005772*x^5+8693412*x^4+45161844*x^3+5948124*x^2, 173699400*x^5+106253112*x^4+10981152*x^3-88911732*x^2 ], [ 1450*x^4+1161*x^3+162*x^2, 1400*x^3+252*x^2, 0, 0, 450*x+81, 0, 0, 500*x^4+90*x^3+800*x^2+144*x, 2350*x^3+2523*x^2+1028*x+117, 0 ], [ 0, 0, 0, 0, 71464896*x^5+40678308*x^4-54505188*x^3-18377568*x^2+5686668*x, 29777040*x^5+35187732*x^4+4117932*x^3+420*x^2+555*x+240, 55087524*x^4+32566428*x^3+3333564*x^2-61554276*x, 53598672*x^2+7059312*x, 28288188*x^5+3725748*x^4+19355076*x^3+2549196*x^2, 74442600*x^5+45537048*x^4+4706358*x^3-38105028*x^2+720*x+480 ], [ 0, 0, 0, 0, -3970272000*x^4-2259906000*x^3+3028066000*x^2+1020976000*x-315926000, -1654280000*x^4-1954874000*x^3-228774000*x^2, -3060418000*x^3-1809216000*x^2-185198000*x+3419682000, -2977704000*x-392184000, -1571566000*x^4-206986000*x^3-1075282000*x^2-141622000*x, -4135700000*x^4-2529836000*x^3-261456000*x^2+2116946000*x ] ]", 5, 10, Qx );;
gap> f := PresentationMorphism( M, f_mat, N );;
gap> g_mat := HomalgMatrix( "[ [ 29*x^3+18*x^2, 28*x^2, 0, 0, 9, 0, 0, 10*x^3+16*x, 47*x^2+42*x+13, 0 ], [ 0, 0, 0, 0, 0, 28*x^2+37*x+16, 36*x^3, 0, 0, 10*x^3+48*x+32 ], [ 0, 0, 0, 0, 1985136*x^4+1129953*x^3-1514033*x^2-510488*x+157963, 827140*x^4+977437*x^3+114387*x^2, 1530209*x^3+904608*x^2+92599*x-1709841, 1488852*x+196092, 785783*x^4+103493*x^3+537641*x^2+70811*x, 2067850*x^4+1264918*x^3+130728*x^2-1058473*x ], [ 43*x, 0, 0, 0, 5*x, 0, 0, 0, 14*x^3, 34 ] ]", 4, 10, Qx );;
gap> g := PresentationMorphism( P, g_mat, N );;
gap> l := Lift( f, g );;
gap> Assert( 0, PreCompose( l, Colift( l, f ) ) = f and PreCompose( l, g ) = f );
gap> Qx_rpres := RightPresentations( Qx );;
gap> M := AsRightPresentation( TransposedMatrix( M_mat ) );;
gap> N := AsRightPresentation( TransposedMatrix( N_mat ) );;
gap> P := AsRightPresentation( TransposedMatrix( P_mat ) );;
gap> f := PresentationMorphism( M, TransposedMatrix( f_mat ), N );;
gap> g := PresentationMorphism( P, TransposedMatrix( g_mat ), N );;
gap> l := Lift( f, g );;
gap> Assert( 0, PreCompose( l, Colift( l, f ) ) = f and PreCompose( l, g ) = f );;

gap> STOP_TEST( "Lift/Colift" );