From 54bba6a379ab1adb9f69e77ee9f6e6a4962ae873 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Mon, 31 May 2021 18:07:28 +0200 Subject: [PATCH] Add Lift/Colift/SolveLinearSystemInAbCategoryOrFail Lift/Colift/SolveLinearSystemInAbCategory now assume that a lift/colift/ solution exists. --- CAP/PackageInfo.g | 2 +- CAP/examples/HomStructureTest.g | 19 +- CAP/gap/CategoryMorphisms.gd | 132 +++++-- CAP/gap/DerivedMethods.gi | 255 ++++++++++--- CAP/gap/MethodRecord.gi | 76 ++-- CompilerForCAP/PackageInfo.g | 4 +- ...P_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL.g | 10 +- .../examples/PrecompileLinearAlgebraForCAP.g | 1 + .../PrecompileOppositeOfLinearAlgebraForCAP.g | 4 +- CompilerForCAP/gap/PrecompileCategory.gi | 2 + FreydCategoriesForCAP/PackageInfo.g | 4 +- FreydCategoriesForCAP/examples/Prosets.g | 4 +- FreydCategoriesForCAP/gap/AdelmanCategory.gd | 15 +- FreydCategoriesForCAP/gap/AdelmanCategory.gi | 35 +- .../CategoryOfGradedColumns.gi | 55 ++- .../CategoryOfGradedRows.gi | 55 ++- .../gap/CokernelImageClosure.gd | 3 + .../gap/CokernelImageClosure.gi | 42 ++- .../gap/FreydCategoriesDerivedMethods.gi | 10 - FreydCategoriesForCAP/gap/FreydCategory.gi | 1 - GradedModulePresentationsForCAP/PackageInfo.g | 4 +- .../examples/CohP1.g | 2 +- LinearAlgebraForCAP/PackageInfo.g | 4 +- .../gap/LinearAlgebraForCAP.gi | 42 +++ .../MatrixCategoryPrecompiled.gi | 66 +--- .../OppositeOfMatrixCategoryPrecompiled.gi | 64 +++- ModulePresentationsForCAP/PackageInfo.g | 4 +- .../gap/ModulePresentationsForCAP.gi | 342 +++++++++++++----- 28 files changed, 937 insertions(+), 320 deletions(-) diff --git a/CAP/PackageInfo.g b/CAP/PackageInfo.g index 14ac6a7b51..1322cce325 100644 --- a/CAP/PackageInfo.g +++ b/CAP/PackageInfo.g @@ -21,7 +21,7 @@ Version := Maximum( [ ## this line prevents merge conflicts "2020.04-16", ## Sepp's version ## this line prevents merge conflicts - "2021.05-03", ## Fabian's version + "2021.06-01", ## Fabian's version ## this line prevents merge conflicts "2021.05-04", ## Kamal's version ] ), diff --git a/CAP/examples/HomStructureTest.g b/CAP/examples/HomStructureTest.g index 0ecf4bcd6b..b9b991171b 100644 --- a/CAP/examples/HomStructureTest.g +++ b/CAP/examples/HomStructureTest.g @@ -42,12 +42,27 @@ ForAll( [ 1, 2 ], i -> ) ); #! true -Lift( c, d ); + +IsLiftable( c, d ); +#! false +LiftOrFail( c, d ); #! fail +IsLiftable( d, c ); +#! true +LiftOrFail( d, c ); +#! 0 Lift( d, c ); #! 0 + +IsColiftable( c, d ); +#! true +ColiftOrFail( c, d ); +#! 0 Colift( c, d ); #! 0 -Colift( d, c ); +IsColiftable( d, c ); +#! false +ColiftOrFail( d, c ); #! fail + #! @EndExample diff --git a/CAP/gap/CategoryMorphisms.gd b/CAP/gap/CategoryMorphisms.gd index be655cbecb..681e0af458 100644 --- a/CAP/gap/CategoryMorphisms.gd +++ b/CAP/gap/CategoryMorphisms.gd @@ -1559,12 +1559,12 @@ DeclareOperation( "AddIsColiftableAlongEpimorphism", [ IsCapCategory, IsList ] ); #! @Description -#! The arguments are two morphisms $\alpha: a \rightarrow c$, $\beta: b \rightarrow c$. -#! The output is a lift $\alpha / \beta: a \rightarrow b$ of $\alpha$ along $\beta$ -#! if such a lift exists or $\mathtt{fail}$ if it doesn't. +#! The arguments are two morphisms $\alpha: a \rightarrow c$, $\beta: b \rightarrow c$ +#! such that a lift $\alpha / \beta: a \rightarrow b$ of $\alpha$ along $\beta$ exists. +#! The output is such a lift $\alpha / \beta: a \rightarrow b$. #! Recall that a lift $\alpha / \beta: a \rightarrow b$ of $\alpha$ along $\beta$ is #! a morphism such that $\beta \circ (\alpha / \beta) \sim_{a,c} \alpha$. -#! @Returns a morphism in $\mathrm{Hom}(a,b) + \{ \mathtt{fail} \}$ +#! @Returns a morphism in $\mathrm{Hom}(a,b)$ #! @Arguments alpha, beta DeclareOperation( "Lift", [ IsCapCategoryMorphism, IsCapCategoryMorphism ] ); @@ -1573,8 +1573,7 @@ DeclareOperation( "Lift", #! The arguments are a category $C$ and a function $F$. #! This operation adds the given function $F$ #! to the category for the basic operation Lift. -#! The function $F$ maps a pair $(\alpha, \beta)$ to a lift $\alpha / \beta$ if it -#! exists, and to fail otherwise. +#! The function $F$ maps a pair $(\alpha, \beta)$ to a lift $\alpha / \beta$. #! @Returns nothing #! @Arguments C, F DeclareOperation( "AddLift", @@ -1589,37 +1588,35 @@ DeclareOperation( "AddLift", DeclareOperation( "AddLift", [ IsCapCategory, IsList ] ); -## #! @Description -#! The arguments are two morphisms $\alpha: a \rightarrow c$, $\beta: a \rightarrow b$. -#! The output is a colift $\alpha \backslash \beta: c \rightarrow b$ of $\beta$ along $\alpha$ -#! if such a colift exists or $\mathtt{fail}$ if it doesn't. -#! Recall that a colift $\alpha \backslash \beta: c \rightarrow b$ of $\beta$ along $\alpha$ is -#! a morphism such that $(\alpha \backslash \beta) \circ \alpha \sim_{a,b} \beta$. -#! @Returns a morphism in $\mathrm{Hom}(c,b) + \{ \mathtt{fail} \}$ +#! The arguments are two morphisms $\alpha: a \rightarrow c$, $\beta: b \rightarrow c$. +#! The output is a lift $\alpha / \beta: a \rightarrow b$ of $\alpha$ along $\beta$ +#! if such a lift exists or $\mathtt{fail}$ if it doesn't. +#! Recall that a lift $\alpha / \beta: a \rightarrow b$ of $\alpha$ along $\beta$ is +#! a morphism such that $\beta \circ (\alpha / \beta) \sim_{a,c} \alpha$. +#! @Returns a morphism in $\mathrm{Hom}(a,b) + \{ \mathtt{fail} \}$ #! @Arguments alpha, beta -DeclareOperation( "Colift", +DeclareOperation( "LiftOrFail", [ IsCapCategoryMorphism, IsCapCategoryMorphism ] ); - #! @Description #! The arguments are a category $C$ and a function $F$. #! This operation adds the given function $F$ -#! to the category for the basic operation Colift. -#! The function $F$ maps a pair $(\alpha, \beta)$ to a colift $\alpha \backslash \beta$ if it +#! to the category for the basic operation LiftOrFail. +#! The function $F$ maps a pair $(\alpha, \beta)$ to a lift $\alpha / \beta$ if it #! exists, and to fail otherwise. #! @Returns nothing #! @Arguments C, F -DeclareOperation( "AddColift", +DeclareOperation( "AddLiftOrFail", [ IsCapCategory, IsFunction ] ); -DeclareOperation( "AddColift", +DeclareOperation( "AddLiftOrFail", [ IsCapCategory, IsFunction, IsInt ] ); -DeclareOperation( "AddColift", +DeclareOperation( "AddLiftOrFail", [ IsCapCategory, IsList, IsInt ] ); -DeclareOperation( "AddColift", +DeclareOperation( "AddLiftOrFail", [ IsCapCategory, IsList ] ); #! @Description @@ -1652,8 +1649,69 @@ DeclareOperation( "AddIsLiftable", DeclareOperation( "AddIsLiftable", [ IsCapCategory, IsList ] ); +#! @Description +#! The arguments are two morphisms $\alpha: a \rightarrow c$, $\beta: a \rightarrow b$ +#! such that a colift $\alpha \backslash \beta: c \rightarrow b$ of $\beta$ along $\alpha$ exists. +#! The output is such a colift $\alpha \backslash \beta: c \rightarrow b$. +#! Recall that a colift $\alpha \backslash \beta: c \rightarrow b$ of $\beta$ along $\alpha$ is +#! a morphism such that $(\alpha \backslash \beta) \circ \alpha \sim_{a,b} \beta$. +#! @Returns a morphism in $\mathrm{Hom}(c,b)$ +#! @Arguments alpha, beta +DeclareOperation( "Colift", + [ IsCapCategoryMorphism, IsCapCategoryMorphism ] ); + + +#! @Description +#! The arguments are a category $C$ and a function $F$. +#! This operation adds the given function $F$ +#! to the category for the basic operation Colift. +#! The function $F$ maps a pair $(\alpha, \beta)$ to a colift $\alpha \backslash \beta$. +#! @Returns nothing +#! @Arguments C, F +DeclareOperation( "AddColift", + [ IsCapCategory, IsFunction ] ); + +DeclareOperation( "AddColift", + [ IsCapCategory, IsFunction, IsInt ] ); + +DeclareOperation( "AddColift", + [ IsCapCategory, IsList, IsInt ] ); + +DeclareOperation( "AddColift", + [ IsCapCategory, IsList ] ); + +#! @Description +#! The arguments are two morphisms $\alpha: a \rightarrow c$, $\beta: a \rightarrow b$. +#! The output is a colift $\alpha \backslash \beta: c \rightarrow b$ of $\beta$ along $\alpha$ +#! if such a colift exists or $\mathtt{fail}$ if it doesn't. +#! Recall that a colift $\alpha \backslash \beta: c \rightarrow b$ of $\beta$ along $\alpha$ is +#! a morphism such that $(\alpha \backslash \beta) \circ \alpha \sim_{a,b} \beta$. +#! @Returns a morphism in $\mathrm{Hom}(c,b) + \{ \mathtt{fail} \}$ +#! @Arguments alpha, beta +DeclareOperation( "ColiftOrFail", + [ IsCapCategoryMorphism, IsCapCategoryMorphism ] ); + + +#! @Description +#! The arguments are a category $C$ and a function $F$. +#! This operation adds the given function $F$ +#! to the category for the basic operation ColiftOrFail. +#! The function $F$ maps a pair $(\alpha, \beta)$ to a colift $\alpha \backslash \beta$ if it +#! exists, and to fail otherwise. +#! @Returns nothing +#! @Arguments C, F +DeclareOperation( "AddColiftOrFail", + [ IsCapCategory, IsFunction ] ); + +DeclareOperation( "AddColiftOrFail", + [ IsCapCategory, IsFunction, IsInt ] ); + +DeclareOperation( "AddColiftOrFail", + [ IsCapCategory, IsList, IsInt ] ); + +DeclareOperation( "AddColiftOrFail", + [ IsCapCategory, IsList ] ); -## #! @Description #! The arguments are two morphisms $\alpha: a \rightarrow c$, $\beta: a \rightarrow b$. #! The output is true if there exists @@ -2003,12 +2061,11 @@ DeclareOperation( "AddInterpretMorphismFromDistinguishedObjectToHomomorphismStru #! where $i = 1 \dots m$ and $j = 1 \dots n$. #! The third list $\gamma$ (the right side) is a list of morphisms $\gamma_i: A_i \rightarrow D_i$, #! where $i = 1, \dots, m$. -#! The output is either -#! a list of morphisms $X_j: B_j \rightarrow C_j$ for $j=1\dots n$ solving the linear system -#! defined by $\alpha$, $\beta$, $\gamma$, i.e., +#! Assumes that a solution to the linear system defined by $\alpha$, $\beta$, $\gamma$ exists, i.e., +#! there exist morphisms $X_j: B_j \rightarrow C_j$ for $j=1\dots n$ such that #! $\sum_{j = 1}^n \alpha_{ij}\cdot X_j \cdot \beta_{ij} = \gamma_i$ -#! for all $i = 1 \dots m$, -#! or $\texttt{fail}$ if no such solution exists. +#! for all $i = 1 \dots m$. +#! The output is list of such morphisms $X_j: B_j \rightarrow C_j$ for $j=1\dots n$. #! @Returns a list of morphisms $[X_1, \dots, X_n]$ #! @Arguments alpha, beta, gamma DeclareOperation( "SolveLinearSystemInAbCategory", @@ -2026,6 +2083,27 @@ DeclareOperation( "AddSolveLinearSystemInAbCategory", DeclareOperation( "AddSolveLinearSystemInAbCategory", [ IsCapCategory, IsList ] ); +#! @Description +#! Like SolveLinearSystemInAbCategory, +#! but without the assumption that a solution exists. +#! If no solution exists, `fail` is returned. +#! @Returns a list of morphisms $[X_1, \dots, X_n]$ or `fail` +#! @Arguments alpha, beta, gamma +DeclareOperation( "SolveLinearSystemInAbCategoryOrFail", + [ IsList, IsList, IsList ] ); + +DeclareOperation( "AddSolveLinearSystemInAbCategoryOrFail", + [ IsCapCategory, IsFunction ] ); + +DeclareOperation( "AddSolveLinearSystemInAbCategoryOrFail", + [ IsCapCategory, IsFunction, IsInt ] ); + +DeclareOperation( "AddSolveLinearSystemInAbCategoryOrFail", + [ IsCapCategory, IsList, IsInt ] ); + +DeclareOperation( "AddSolveLinearSystemInAbCategoryOrFail", + [ IsCapCategory, IsList ] ); + #! @Description #! Like SolveLinearSystemInAbCategory, #! but the output is simply true if a solution exists, diff --git a/CAP/gap/DerivedMethods.gi b/CAP/gap/DerivedMethods.gi index 4326f64039..cd4be8f439 100644 --- a/CAP/gap/DerivedMethods.gi +++ b/CAP/gap/DerivedMethods.gi @@ -1169,41 +1169,23 @@ AddDerivationToCAP( IsCodominating, end : Description := "IsCodominating(factor1, factor2) by deciding if KernelEmbedding( cat,factor2) composed with factor1 is zero" ); -## -AddDerivationToCAP( IsLiftable, - [ [ Lift, 1 ] ], - function( cat, alpha, beta ) - - return IsCapCategoryMorphism( Lift( cat, alpha, beta ) ); - -end : Description := "IsLiftable using Lift" ); - ## AddDerivationToCAP( IsLiftableAlongMonomorphism, - [ [ Lift, 1 ] ], + [ [ IsLiftable, 1 ] ], function( cat, iota, tau ) - return IsCapCategoryMorphism( Lift( cat, tau, iota ) ); + return IsLiftable( cat, tau, iota ); -end : Description := "IsLiftableAlongMonomorphism using Lift" ); - -## -AddDerivationToCAP( IsColiftable, - [ [ Colift, 1 ] ], - function( cat, alpha, beta ) - - return IsCapCategoryMorphism( Colift( cat, alpha, beta ) ); - -end : Description := "IsColiftable using Colift" ); +end : Description := "IsLiftableAlongMonomorphism using IsLiftable" ); ## AddDerivationToCAP( IsColiftableAlongEpimorphism, - [ [ Colift, 1 ] ], + [ [ IsColiftable, 1 ] ], function( cat, epsilon, tau ) - return IsCapCategoryMorphism( Colift( cat, epsilon, tau ) ); + return IsColiftable( cat, epsilon, tau ); -end : Description := "IsColiftableAlongEpimorphism using Colift" ); +end : Description := "IsColiftableAlongEpimorphism using IsColiftable" ); ########################### ## @@ -1313,7 +1295,6 @@ AddDerivationToCAP( LiftAlongMonomorphism, function( cat, alpha, beta ) ## Caution with the order of the arguments! - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Lift( cat, beta, alpha ); end : Description := "LiftAlongMonomorphism using Lift" ); @@ -1324,7 +1305,6 @@ AddDerivationToCAP( ProjectiveLift, function( cat, alpha, beta ) - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Lift( cat, alpha, beta ); end : Description := "ProjectiveLift using Lift" ); @@ -1336,7 +1316,6 @@ AddDerivationToCAP( ColiftAlongEpimorphism, function( cat, alpha, beta ) - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Colift( cat, alpha, beta ); end : Description := "ColiftAlongEpimorphism using Colift" ); @@ -1347,7 +1326,6 @@ AddDerivationToCAP( InjectiveColift, function( cat, alpha, beta ) - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Colift( cat, alpha, beta ); end : Description := "InjectiveColift using Colift" ); @@ -2450,6 +2428,26 @@ AddDerivationToCAP( Lift, right_divide := SolveLinearSystemInAbCategory( cat, left_coefficients, right_coefficients, right_side ); + return right_divide[1]; + +end : Description := "Lift by SolveLinearSystemInAbCategory" ); + +## +AddDerivationToCAP( LiftOrFail, + [ [ IdentityMorphism, 1 ], + [ SolveLinearSystemInAbCategoryOrFail, 1 ] ], + function( cat, alpha, beta ) + local left_coefficients, right_coefficients, right_side, right_divide; + + left_coefficients := [ [ IdentityMorphism( cat, Source( alpha ) ) ] ]; + + right_coefficients := [ [ beta ] ]; + + right_side := [ alpha ]; + + right_divide := SolveLinearSystemInAbCategoryOrFail( cat, + left_coefficients, right_coefficients, right_side ); + if right_divide = fail then return fail; @@ -2458,8 +2456,26 @@ AddDerivationToCAP( Lift, return right_divide[1]; -end : Description := "Lift by SolveLinearSystemInAbCategory" ); - +end : Description := "LiftOrFail by SolveLinearSystemInAbCategoryOrFail" ); + +## +AddDerivationToCAP( IsLiftable, + [ [ IdentityMorphism, 1 ], + [ MereExistenceOfSolutionOfLinearSystemInAbCategory, 1 ] ], + function( cat, alpha, beta ) + local left_coefficients, right_coefficients, right_side; + + left_coefficients := [ [ IdentityMorphism( cat, Source( alpha ) ) ] ]; + + right_coefficients := [ [ beta ] ]; + + right_side := [ alpha ]; + + return MereExistenceOfSolutionOfLinearSystemInAbCategory( cat, + left_coefficients, right_coefficients, right_side ); + +end : Description := "IsLiftable by MereExistenceOfSolutionOfLinearSystemInAbCategory" ); + ## AddDerivationToCAP( Colift, [ [ IdentityMorphism, 1 ], @@ -2476,6 +2492,26 @@ AddDerivationToCAP( Colift, left_divide := SolveLinearSystemInAbCategory( cat, left_coefficients, right_coefficients, right_side ); + return left_divide[1]; + +end : Description := "Colift by SolveLinearSystemInAbCategory" ); + +## +AddDerivationToCAP( ColiftOrFail, + [ [ IdentityMorphism, 1 ], + [ SolveLinearSystemInAbCategoryOrFail, 1 ] ], + function( cat, alpha, beta ) + local left_coefficients, right_coefficients, right_side, left_divide; + + left_coefficients := [ [ alpha ] ]; + + right_coefficients := [ [ IdentityMorphism( cat, Range( beta ) ) ] ]; + + right_side := [ beta ]; + + left_divide := SolveLinearSystemInAbCategoryOrFail( cat, + left_coefficients, right_coefficients, right_side ); + if left_divide = fail then return fail; @@ -2484,7 +2520,79 @@ AddDerivationToCAP( Colift, return left_divide[1]; -end : Description := "Colift by SolveLinearSystemInAbCategory" ); +end : Description := "ColiftOrFail by SolveLinearSystemInAbCategoryOrFail" ); + +## +AddDerivationToCAP( IsColiftable, + [ [ IdentityMorphism, 1 ], + [ MereExistenceOfSolutionOfLinearSystemInAbCategory, 1 ] ], + function( cat, alpha, beta ) + local left_coefficients, right_coefficients, right_side; + + left_coefficients := [ [ alpha ] ]; + + right_coefficients := [ [ IdentityMorphism( cat, Range( beta ) ) ] ]; + + right_side := [ beta ]; + + return MereExistenceOfSolutionOfLinearSystemInAbCategory( cat, + left_coefficients, right_coefficients, right_side ); + +end : Description := "IsColiftable by MereExistenceOfSolutionOfLinearSystemInAbCategory" ); + +## +AddDerivationToCAP( LiftOrFail, + [ [ IsLiftable, 1 ], + [ Lift, 1 ] ], + function( cat, alpha, beta ) + + if IsLiftable( cat, alpha, beta ) then + + return Lift( cat, alpha, beta ); + + else + + return fail; + + fi; + +end : Description := "LiftOrFail using IsLiftable and Lift" ); + +## +AddDerivationToCAP( ColiftOrFail, + [ [ IsColiftable, 1 ], + [ Colift, 1 ] ], + function( cat, alpha, beta ) + + if IsColiftable( cat, alpha, beta ) then + + return Colift( cat, alpha, beta ); + + else + + return fail; + + fi; + +end : Description := "ColiftOrFail using IsColiftable and Colift" ); + +## +AddDerivationToCAP( SolveLinearSystemInAbCategoryOrFail, + [ [ MereExistenceOfSolutionOfLinearSystemInAbCategory, 1 ], + [ SolveLinearSystemInAbCategory, 1 ] ], + function( cat, left_coefficients, right_coefficients, right_side ) + + if MereExistenceOfSolutionOfLinearSystemInAbCategory( cat, left_coefficients, right_coefficients, right_side ) then + + return SolveLinearSystemInAbCategory( cat, left_coefficients, right_coefficients, right_side ); + + else + + return fail; + + fi; + +end : Description := "SolveLinearSystemInAbCategoryOrFail using MereExistenceOfSolutionOfLinearSystemInAbCategory and SolveLinearSystemInAbCategory" ); ## AddDerivationToCAP( IsomorphismFromItsConstructionAsAnImageObjectToHomologyObject, @@ -2849,12 +2957,6 @@ AddDerivationToCAP( SolveLinearSystemInAbCategory, ## the actual computation of the solution lift := Lift( range_cat, nu, H ); - if lift = fail then - - return fail; - - fi; - ## reinterpretation of the solution summands := List( [ 1 .. n ], j -> HomomorphismStructureOnObjects( cat, Range( left_coefficients[1][j] ), Source( right_coefficients[1][j] ) ) ); @@ -2897,13 +2999,84 @@ AddDerivationToCAP( SolveLinearSystemInAbCategory, ); ## -AddDerivationToCAP( MereExistenceOfSolutionOfLinearSystemInAbCategory, - [ [ SolveLinearSystemInAbCategory, 1 ] ], +AddDerivationToCAP( SolveLinearSystemInAbCategoryOrFail, + [ [ InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure, 1 ], + [ HomomorphismStructureOnMorphismsWithGivenObjects, 1 ], + [ HomomorphismStructureOnObjects, 1 ], + [ InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism, 1 ] ], function( cat, left_coefficients, right_coefficients, right_side ) + local range_cat, m, n, nu, H, lift, summands, list; + + range_cat := RangeCategoryOfHomomorphismStructure( cat ); - return SolveLinearSystemInAbCategory( cat, left_coefficients, right_coefficients, right_side ) <> fail; + m := Size( left_coefficients ); + + n := Size( left_coefficients[1] ); -end : Description := "MereExistenceOfSolutionOfLinearSystemInAbCategory using SolveLinearSystemInAbCategory" ); + ## create lift diagram + + nu := + UniversalMorphismIntoDirectSum( range_cat, + List( [ 1 .. m ], + i -> InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure( cat, right_side[i] ) ) + ); + + list := + List( [ 1 .. n ], + j -> List( [ 1 .. m ], i -> HomomorphismStructureOnMorphisms( left_coefficients[i][j], right_coefficients[i][j] ) ) + ); + + H := MorphismBetweenDirectSums( list ); + + ## the actual computation of the solution + lift := LiftOrFail( range_cat, nu, H ); + + if lift = fail then + + return fail; + + fi; + + ## reinterpretation of the solution + summands := List( [ 1 .. n ], j -> HomomorphismStructureOnObjects( cat, Range( left_coefficients[1][j] ), Source( right_coefficients[1][j] ) ) ); + + return + List( [ 1 .. n ], j -> + InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism( cat, + Range( left_coefficients[1][j] ), + Source( right_coefficients[1][j] ), + PreCompose( range_cat, lift, ProjectionInFactorOfDirectSum( range_cat, summands, j ) ) + ) + ); + end : + ConditionsListComplete := true, + CategoryFilter := function( cat ) + local B, conditions; + + if HasIsAbCategory( cat ) and IsAbCategory( cat ) and HasRangeCategoryOfHomomorphismStructure( cat ) then + + B := RangeCategoryOfHomomorphismStructure( cat ); + + conditions := [ + "UniversalMorphismIntoDirectSum", + "MorphismBetweenDirectSumsWithGivenDirectSums", + "LiftOrFail", + "PreCompose" + ]; + + if ForAll( conditions, c -> CanCompute( B, c ) ) then + + return true; + + fi; + + fi; + + return false; + + end, + Description := "SolveLinearSystemInAbCategoryOrFail using the homomorphism structure" +); ## AddDerivationToCAP( MereExistenceOfSolutionOfLinearSystemInAbCategory, diff --git a/CAP/gap/MethodRecord.gi b/CAP/gap/MethodRecord.gi index f87db31d2d..1477feb106 100644 --- a/CAP/gap/MethodRecord.gi +++ b/CAP/gap/MethodRecord.gi @@ -135,7 +135,7 @@ Lift := rec( filter_list := [ "category", "morphism", "morphism" ], io_type := [ [ "alpha", "beta" ], [ "alpha_source", "beta_source" ] ], pre_function := function( cat, iota, tau ) - local value, category; + local value; value := IsEqualForObjects( Range( iota ), Range( tau ) ); @@ -151,30 +151,23 @@ Lift := rec( return [ true ]; end, - return_type := "morphism_or_fail", + return_type := "morphism", dual_operation := "Colift", dual_arguments_reversed := true, is_merely_set_theoretic := true ), +LiftOrFail := rec( + filter_list := [ "category", "morphism", "morphism" ], + io_type := [ [ "alpha", "beta" ], [ "alpha_source", "beta_source" ] ], + pre_function := ~.Lift.pre_function, + return_type := "morphism_or_fail", + dual_operation := "ColiftOrFail", + dual_arguments_reversed := true, + is_merely_set_theoretic := true ), + IsLiftable := rec( filter_list := [ "category", "morphism", "morphism" ], - pre_function := function( cat, iota, tau ) - local value; - - value := IsEqualForObjects( Range( iota ), Range( tau ) ); - - if value = fail then - - return [ false, "cannot decide whether the two morphisms have equal ranges" ]; - - elif value = false then - - return [ false, "the two morphisms must have equal ranges" ]; - - fi; - - return [ true ]; - end, + pre_function := ~.Lift.pre_function, return_type := "bool", dual_operation := "IsColiftable", dual_arguments_reversed := true ), @@ -183,7 +176,7 @@ Colift := rec( filter_list := [ "category", "morphism", "morphism" ], io_type := [ [ "alpha", "beta" ], [ "alpha_range", "beta_range" ] ], pre_function := function( cat, epsilon, tau ) - local value, category; + local value; value := IsEqualForObjects( Source( epsilon ), Source( tau ) ); @@ -199,30 +192,23 @@ Colift := rec( return [ true ]; end, - return_type := "morphism_or_fail", + return_type := "morphism", dual_operation := "Lift", dual_arguments_reversed := true, is_merely_set_theoretic := true ), +ColiftOrFail := rec( + filter_list := [ "category", "morphism", "morphism" ], + io_type := [ [ "alpha", "beta" ], [ "alpha_range", "beta_range" ] ], + pre_function := ~.Colift.pre_function, + return_type := "morphism_or_fail", + dual_operation := "LiftOrFail", + dual_arguments_reversed := true, + is_merely_set_theoretic := true ), + IsColiftable := rec( filter_list := [ "category", "morphism", "morphism" ], - pre_function := function( cat, epsilon, tau ) - local value; - - value := IsEqualForObjects( Source( epsilon ), Source( tau ) ); - - if value = fail then - - return [ false, "cannot decide whether the two morphisms have equal sources" ]; - - elif value = false then - - return [ false, "the two morphisms must have equal sources" ]; - - fi; - - return [ true ]; - end, + pre_function := ~.Colift.pre_function, return_type := "bool", dual_operation := "IsLiftable", dual_arguments_reversed := true ), @@ -2981,7 +2967,7 @@ InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism := rec SolveLinearSystemInAbCategory := rec( filter_list := [ "category", IsList, IsList, "list_of_morphisms" ], - return_type := "list_of_morphisms_or_fail", + return_type := "list_of_morphisms", pre_function := function( cat, left_coeffs, right_coeffs, rhs ) if not Length( left_coeffs ) > 0 then @@ -3026,10 +3012,18 @@ SolveLinearSystemInAbCategory := rec( end, ), +SolveLinearSystemInAbCategoryOrFail := rec( + filter_list := [ "category", IsList, IsList, "list_of_morphisms" ], + return_type := "list_of_morphisms_or_fail", + pre_function := ~.SolveLinearSystemInAbCategory.pre_function, + pre_function_full := ~.SolveLinearSystemInAbCategory.pre_function_full +), + MereExistenceOfSolutionOfLinearSystemInAbCategory := rec( - ## TODO: Type-check of linear system filter_list := [ "category", IsList, IsList, "list_of_morphisms" ], - return_type := "bool" + return_type := "bool", + pre_function := ~.SolveLinearSystemInAbCategory.pre_function, + pre_function_full := ~.SolveLinearSystemInAbCategory.pre_function_full ), BasisOfExternalHom := rec( diff --git a/CompilerForCAP/PackageInfo.g b/CompilerForCAP/PackageInfo.g index ba16230362..509ea7326e 100644 --- a/CompilerForCAP/PackageInfo.g +++ b/CompilerForCAP/PackageInfo.g @@ -11,7 +11,7 @@ SetPackageInfo( rec( PackageName := "CompilerForCAP", Subtitle := "Speed up computations in CAP categories", Version := Maximum( [ - "2021.05-01", ## Fabian's version + "2021.06-01", ## Fabian's version ## this line prevents merge conflicts ] ), Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ), @@ -72,7 +72,7 @@ PackageDoc := rec( Dependencies := rec( GAP := ">= 4.11", NeededOtherPackages := [ - [ "CAP", ">= 2021.05-01" ], + [ "CAP", ">= 2021.06-01" ], ], SuggestedOtherPackages := [ ], ExternalConditions := [ ], diff --git a/CompilerForCAP/examples/CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL.g b/CompilerForCAP/examples/CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL.g index 37fb385e10..89defadb07 100644 --- a/CompilerForCAP/examples/CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL.g +++ b/CompilerForCAP/examples/CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL.g @@ -9,9 +9,9 @@ LoadPackage( "LinearAlgebraForCAP" ); Q := HomalgFieldOfRationals();; rows := MatrixCategory( Q );; -MyKernelLift := function( cat, mor, test_morphism ) +MyKernelLift := function( cat, mor, test_mor ) #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL - return Lift( cat, test_morphism, KernelEmbedding( cat, mor ) ); end;; + return LiftOrFail( cat, test_mor, KernelEmbedding( cat, mor ) ); end;; V := VectorSpaceObject( 2, Q );; compiled_func := CapJitCompiledFunction( @@ -19,14 +19,14 @@ compiled_func := CapJitCompiledFunction( [ rows, ZeroMorphism( V, V ), IdentityMorphism( V ) ] );; Display( compiled_func ); -#! function ( cat, mor, test_morphism ) +#! function ( cat, mor, test_mor ) #! local cap_jit_morphism_attribute; #! cap_jit_morphism_attribute -#! := RightDivide( UnderlyingMatrix( test_morphism ), +#! := RightDivide( UnderlyingMatrix( test_mor ), #! SyzygiesOfRows( UnderlyingMatrix( mor ) ) ); #! return ObjectifyWithAttributes( rec( #! ), MorphismType( cat ), CapCategory, cat, Source, -#! Source( test_morphism ), Range, ObjectifyWithAttributes( rec( +#! Source( test_mor ), Range, ObjectifyWithAttributes( rec( #! ), ObjectType( cat ), CapCategory, cat, Dimension, #! NrColumns( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, #! UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, diff --git a/CompilerForCAP/examples/PrecompileLinearAlgebraForCAP.g b/CompilerForCAP/examples/PrecompileLinearAlgebraForCAP.g index 5989a60a9a..023f1ec36a 100644 --- a/CompilerForCAP/examples/PrecompileLinearAlgebraForCAP.g +++ b/CompilerForCAP/examples/PrecompileLinearAlgebraForCAP.g @@ -37,6 +37,7 @@ operations := Filtered( operations, operations := Difference( operations, [ "DirectSumCodiagonalDifference" ] );; operations := Difference( operations, [ "DirectSumDiagonalDifference" ] );; operations := Difference( operations, [ "HomologyObject" ] );; +operations := Difference( operations, [ "LiftOrFail", "ColiftOrFail" ] );; # IsEqualForMorphismsOnMor causes problems in GAP 4.11 (see GAP issue #4449) operations := Difference( operations, [ "IsEqualForMorphismsOnMor" ] );; operations := Difference( operations, [ "IsIdenticalToIdentityMorphism" ] );; diff --git a/CompilerForCAP/examples/PrecompileOppositeOfLinearAlgebraForCAP.g b/CompilerForCAP/examples/PrecompileOppositeOfLinearAlgebraForCAP.g index a5540e609e..1e683f1dd5 100644 --- a/CompilerForCAP/examples/PrecompileOppositeOfLinearAlgebraForCAP.g +++ b/CompilerForCAP/examples/PrecompileOppositeOfLinearAlgebraForCAP.g @@ -24,9 +24,9 @@ operations := Intersection( ListPrimitivelyInstalledOperationsOfCategory( MatrixCategory( QQ ) ), CAP_JIT_INTERNAL_SAFE_OPERATIONS );; -# The output for Lift and Colift differs between GAP 4.11 and GAP 4.12, see +# The output for Lift/ColiftOrFail differs between GAP 4.11 and GAP 4.12, see # https://github.com/gap-system/gap/issues/4523 -operations := Difference( operations, [ "Lift", "Colift" ] );; +operations := Difference( operations, [ "LiftOrFail", "ColiftOrFail" ] );; filepath := "precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi";; old_file_content := ReadFileFromPackageForHomalg( package_name, filepath );; diff --git a/CompilerForCAP/gap/PrecompileCategory.gi b/CompilerForCAP/gap/PrecompileCategory.gi index 7b1e7507f9..e2744e9ed2 100644 --- a/CompilerForCAP/gap/PrecompileCategory.gi +++ b/CompilerForCAP/gap/PrecompileCategory.gi @@ -28,6 +28,7 @@ BindGlobal( "CAP_JIT_INTERNAL_SAFE_OPERATIONS", [ "CokernelProjectionWithGivenCokernelObject", "Colift", "ColiftAlongEpimorphism", + "ColiftOrFail", #"ComponentOfMorphismFromDirectSum", #"ComponentOfMorphismIntoDirectSum", "Coproduct", @@ -138,6 +139,7 @@ BindGlobal( "CAP_JIT_INTERNAL_SAFE_OPERATIONS", [ #"KernelObjectFunctorialWithGivenKernelObjects", "Lift", "LiftAlongMonomorphism", + "LiftOrFail", #"MereExistenceOfSolutionOfLinearSystemInAbCategory", "MonomorphismIntoSomeInjectiveObject", "MonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject", diff --git a/FreydCategoriesForCAP/PackageInfo.g b/FreydCategoriesForCAP/PackageInfo.g index b027d11f0c..e04e6ea85f 100644 --- a/FreydCategoriesForCAP/PackageInfo.g +++ b/FreydCategoriesForCAP/PackageInfo.g @@ -17,7 +17,7 @@ Version := Maximum( [ ## this line prevents merge conflicts "2020.05-17", ## Mohamed's version ## this line prevents merge conflicts - "2021.05-03", ## Fabian's version + "2021.06-01", ## Fabian's version ## this line prevents merge conflicts "2020.04-18", ## Kamal's version ] ), @@ -99,7 +99,7 @@ PackageDoc := rec( Dependencies := rec( GAP := ">= 4.8", NeededOtherPackages := [ [ "GAPDoc", ">= 1.5" ], - [ "CAP", ">= 2021.05-01" ], + [ "CAP", ">= 2021.06-01" ], [ "MatricesForHomalg", ">= 2021.04-04" ], [ "GradedRingForHomalg", ">=2019.08.07" ], [ "LinearAlgebraForCAP", ">= 2020.05.16" ], diff --git a/FreydCategoriesForCAP/examples/Prosets.g b/FreydCategoriesForCAP/examples/Prosets.g index 1d684d175b..77faf0975a 100644 --- a/FreydCategoriesForCAP/examples/Prosets.g +++ b/FreydCategoriesForCAP/examples/Prosets.g @@ -42,8 +42,8 @@ beta*Inverse(beta) = IdentityMorphism(b); #! true alpha = Lift(gamma, beta); #! true -fail = Lift(beta, gamma); -#! true +IsLiftable(beta, gamma); +#! false Colift(alpha, gamma) = beta; #! true alpha = HomStructure(a, b, HomStructure(alpha)); diff --git a/FreydCategoriesForCAP/gap/AdelmanCategory.gd b/FreydCategoriesForCAP/gap/AdelmanCategory.gd index 8c95944393..30495e94d0 100644 --- a/FreydCategoriesForCAP/gap/AdelmanCategory.gd +++ b/FreydCategoriesForCAP/gap/AdelmanCategory.gd @@ -256,14 +256,21 @@ DeclareAttribute( "CorelationWitness", IsAdelmanCategoryMorphism ); #! @Description -#! The argument is a morphism $\alpha$ in an Adelman category. -#! If $\alpha$ is congruent to zero, the output is a witness pair. -#! If $\alpha$ is not congruent to zero, the output is fail. -#! @Returns a list of morphisms or fail +#! The argument is a morphism $\alpha$ congruent to zero in an Adelman category. +#! The output is a witness pair. +#! @Returns a list of morphisms #! @Arguments alpha DeclareAttribute( "WitnessPairForBeingCongruentToZero", IsAdelmanCategoryMorphism ); +#! @Description +#! The argument is a morphism $\alpha$ in an Adelman category. +#! The output is `true` if $\alpha$ is congruent to zero, else `false`. +#! @Returns a boolean +#! @Arguments alpha +DeclareAttribute( "MereExistenceOfWitnessPairForBeingCongruentToZero", + IsAdelmanCategoryMorphism ); + DeclareOperation( "HomomorphismStructureOnObjectsForAdelmanCategoryGeneralizedEmbedding", [ IsAdelmanCategoryObject, IsAdelmanCategoryObject ] ); diff --git a/FreydCategoriesForCAP/gap/AdelmanCategory.gi b/FreydCategoriesForCAP/gap/AdelmanCategory.gi index 90d16075f3..e9a77aa6fc 100644 --- a/FreydCategoriesForCAP/gap/AdelmanCategory.gi +++ b/FreydCategoriesForCAP/gap/AdelmanCategory.gi @@ -23,7 +23,7 @@ InstallMethod( AdelmanCategory, fi; - for func in [ "Lift", "Colift", "SubtractionForMorphisms", "AdditionForMorphisms", "PreCompose", "IdentityMorphism" ] do + for func in [ "Lift", "IsLiftable", "Colift", "IsColiftable", "SubtractionForMorphisms", "AdditionForMorphisms", "PreCompose", "IdentityMorphism" ] do if not CanCompute( underlying_category, func ) then @@ -216,6 +216,25 @@ InstallMethod( WitnessPairForBeingCongruentToZero, end ); +## +InstallMethod( MereExistenceOfWitnessPairForBeingCongruentToZero, + [ IsAdelmanCategoryMorphism ], + + function( morphism ) + local datum, left_coeffs, right_coeffs; + + datum := MorphismDatum( morphism ); + + left_coeffs := + [ [ IdentityMorphism( Source( datum ) ), CorelationMorphism( Source( morphism ) ) ] ]; + + right_coeffs := + [ [ RelationMorphism( Range( morphism ) ), IdentityMorphism( Range( datum ) ) ] ]; + + return MereExistenceOfSolutionOfLinearSystemInAbCategory( left_coeffs, right_coeffs, [ datum ] ); + +end ); + ## InstallMethod( IsSequenceAsAdelmanCategoryObject, [ IsAdelmanCategoryObject ], @@ -281,13 +300,13 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_ADELMAN_CATEGORY, AddIsWellDefinedForMorphisms( category, function( morphism ) - if RelationWitness( morphism ) = fail then + if not IsLiftable( PreCompose( RelationMorphism( Source( morphism ) ), MorphismDatum( morphism ) ), RelationMorphism( Range( morphism ) ) ) then return false; fi; - if CorelationWitness( morphism ) = fail then + if not IsColiftable( CorelationMorphism( Source( morphism ) ), PreCompose( MorphismDatum( morphism ), CorelationMorphism( Range( morphism ) ) ) ) then return false; @@ -320,15 +339,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_ADELMAN_CATEGORY, AddIsCongruentForMorphisms( category, function( morphism_1, morphism_2 ) - if WitnessPairForBeingCongruentToZero( SubtractionForMorphisms( morphism_1, morphism_2 ) ) = fail then - - return false; - - else - - return true; - - fi; + return MereExistenceOfWitnessPairForBeingCongruentToZero( SubtractionForMorphisms( morphism_1, morphism_2 ) ); end ); diff --git a/FreydCategoriesForCAP/gap/CategoryOfGradedRowsAndColumns/CategoryOfGradedColumns.gi b/FreydCategoriesForCAP/gap/CategoryOfGradedRowsAndColumns/CategoryOfGradedColumns.gi index 63a32d6e6b..b36229492f 100644 --- a/FreydCategoriesForCAP/gap/CategoryOfGradedRowsAndColumns/CategoryOfGradedColumns.gi +++ b/FreydCategoriesForCAP/gap/CategoryOfGradedRowsAndColumns/CategoryOfGradedColumns.gi @@ -588,6 +588,27 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CAP_CATEGORY_OF_GRADED_COLUMNS, # @Returns a morphism # @Arguments morphism1, morphism2 AddLift( category, + function( morphism1, morphism2 ) + local left_divide, required_degrees, lift; + + # try to find a lift + left_divide := LeftDivide( UnderlyingHomalgMatrix( morphism2 ), UnderlyingHomalgMatrix( morphism1 ) ); + + # identify the homogeneous part of this matrix + required_degrees := List( UnzipDegreeList( Source( morphism2 ) ), + i -> List( UnzipDegreeList( Source( morphism1 ) ), j -> i - j ) ); + lift := HomogeneousPartOfMatrix( left_divide, required_degrees ); + + # and construct the lift + return GradedRowOrColumnMorphism( Source( morphism1 ), + lift, + Source( morphism2 ), + checks + ); + + end ); + + AddLiftOrFail( category, function( morphism1, morphism2 ) local left_divide, required_degrees, lift; @@ -615,12 +636,39 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CAP_CATEGORY_OF_GRADED_COLUMNS, end ); + AddIsLiftable( category, + function( morphism1, morphism2 ) + + return IsZero( DecideZeroColumns( UnderlyingHomalgMatrix( morphism1 ), UnderlyingHomalgMatrix( morphism2 ) ) ); + + end ); + # @Description # This method requires a morphism morphism1 $a \to c$ and a morphism morphism2 $a \to b$. The result of # Colift( morphism1, morphism2 ) is then the colift morphism $c \to b$. # @Returns a morphism # @Arguments morphism1, morphism2 AddColift( category, + function( morphism1, morphism2 ) + local right_divide, required_degrees, colift; + + # try to find a matrix that performs the colift + right_divide := RightDivide( UnderlyingHomalgMatrix( morphism2 ), UnderlyingHomalgMatrix( morphism1 ) ); + + required_degrees := List( UnzipDegreeList( Range( morphism2 ) ), + i -> List( UnzipDegreeList( Range( morphism1 ) ), j -> i - j ) ); + colift := HomogeneousPartOfMatrix( right_divide, required_degrees ); + + # if it did work, return the corresponding morphism + return GradedRowOrColumnMorphism( Range( morphism1 ), + colift, + Range( morphism2 ), + checks + ); + + end ); + + AddColiftOrFail( category, function( morphism1, morphism2 ) local right_divide, required_degrees, colift; @@ -647,7 +695,12 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CAP_CATEGORY_OF_GRADED_COLUMNS, end ); - + AddIsColiftable( category, + function( morphism1, morphism2 ) + + return IsZero( DecideZeroRows( UnderlyingHomalgMatrix( morphism2 ), UnderlyingHomalgMatrix( morphism1 ) ) ); + + end ); ###################################################################### # diff --git a/FreydCategoriesForCAP/gap/CategoryOfGradedRowsAndColumns/CategoryOfGradedRows.gi b/FreydCategoriesForCAP/gap/CategoryOfGradedRowsAndColumns/CategoryOfGradedRows.gi index 7c629f53be..47100d60e0 100644 --- a/FreydCategoriesForCAP/gap/CategoryOfGradedRowsAndColumns/CategoryOfGradedRows.gi +++ b/FreydCategoriesForCAP/gap/CategoryOfGradedRowsAndColumns/CategoryOfGradedRows.gi @@ -594,6 +594,27 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CAP_CATEGORY_OF_GRADED_ROWS, # @Returns a morphism # @Arguments morphism1, morphism2 AddLift( category, + function( morphism1, morphism2 ) + local right_divide, required_degrees, lift; + + # try to find a lift + right_divide := RightDivide( UnderlyingHomalgMatrix( morphism1 ), UnderlyingHomalgMatrix( morphism2 ) ); + + # identify the homogeneous part of this matrix + required_degrees := List( UnzipDegreeList( Source( morphism1 ) ), + i -> List( UnzipDegreeList( Source( morphism2 ) ), j -> j - i ) ); + lift := HomogeneousPartOfMatrix( right_divide, required_degrees ); + + # and construct the lift + return GradedRowOrColumnMorphism( Source( morphism1 ), + lift, + Source( morphism2 ), + checks + ); + + end ); + + AddLiftOrFail( category, function( morphism1, morphism2 ) local right_divide, required_degrees, lift; @@ -621,12 +642,39 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CAP_CATEGORY_OF_GRADED_ROWS, end ); + AddIsLiftable( category, + function( morphism1, morphism2 ) + + return IsZero( DecideZeroRows( UnderlyingHomalgMatrix( morphism1 ), UnderlyingHomalgMatrix( morphism2 ) ) ); + + end ); + # @Description # This method requires a morphism morphism1 $a \to c$ and a morphism morphism2 $a \to b$. The result of # Colift( morphism1, morphism2 ) is then the colift morphism $c \to b$. # @Returns a morphism # @Arguments morphism1, morphism2 AddColift( category, + function( morphism1, morphism2 ) + local left_divide, required_degrees, colift; + + # try to find a matrix that performs the colift + left_divide := LeftDivide( UnderlyingHomalgMatrix( morphism1 ), UnderlyingHomalgMatrix( morphism2 ) ); + + required_degrees := List( UnzipDegreeList( Range( morphism1 ) ), + i -> List( UnzipDegreeList( Range( morphism2 ) ), j -> j - i ) ); + colift := HomogeneousPartOfMatrix( left_divide, required_degrees ); + + # if it did work, return the corresponding morphism + return GradedRowOrColumnMorphism( Range( morphism1 ), + colift, + Range( morphism2 ), + checks + ); + + end ); + + AddColiftOrFail( category, function( morphism1, morphism2 ) local left_divide, required_degrees, colift; @@ -653,7 +701,12 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CAP_CATEGORY_OF_GRADED_ROWS, end ); - + AddIsColiftable( category, + function( morphism1, morphism2 ) + + return IsZero( DecideZeroColumns( UnderlyingHomalgMatrix( morphism2 ), UnderlyingHomalgMatrix( morphism1 ) ) ); + + end ); ###################################################################### # diff --git a/FreydCategoriesForCAP/gap/CokernelImageClosure.gd b/FreydCategoriesForCAP/gap/CokernelImageClosure.gd index 1d612b3536..8bb211fe69 100644 --- a/FreydCategoriesForCAP/gap/CokernelImageClosure.gd +++ b/FreydCategoriesForCAP/gap/CokernelImageClosure.gd @@ -74,6 +74,9 @@ DeclareAttribute( "MorphismWitness", DeclareAttribute( "WitnessForBeingCongruentToZero", IsCokernelImageClosureMorphism ); +DeclareAttribute( "MereExistenceOfWitnessForBeingCongruentToZero", + IsCokernelImageClosureMorphism ); + ####################################### ## #! @Section Functors diff --git a/FreydCategoriesForCAP/gap/CokernelImageClosure.gi b/FreydCategoriesForCAP/gap/CokernelImageClosure.gi index 11cbf9e23a..4b272a79ce 100644 --- a/FreydCategoriesForCAP/gap/CokernelImageClosure.gi +++ b/FreydCategoriesForCAP/gap/CokernelImageClosure.gi @@ -30,6 +30,12 @@ InstallMethod( CokernelImageClosure, fi; + if not CanCompute( underlying_category, "IsLiftable" ) then + + Error( "The given category should be able to compute IsLiftable" ); + + fi; + if not CanCompute( underlying_category, "SubtractionForMorphisms" ) then Error( "The given category should be able to compute SubtractionForMorphisms" ); @@ -201,6 +207,26 @@ InstallMethod( WitnessForBeingCongruentToZero, end ); +## +InstallMethod( MereExistenceOfWitnessForBeingCongruentToZero, + [ IsCokernelImageClosureMorphism ], + + function( morphism ) + local range; + + range := Range( morphism ); + + return + IsLiftable( + PreCompose( + MorphismDatum( morphism ), + GeneratorMorphism( range ) + ), + RelationMorphism( range ) + ); + +end ); + #################################### ## ## Basic operations @@ -253,7 +279,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_COKERNEL_IMAGE_CLOSURE, ## AddIsWellDefinedForMorphisms( category, function( morphism ) - local alpha, lift; + local alpha; alpha := PreCompose( [ RelationOfGeneratorMorphism( Source( morphism ) ), @@ -261,9 +287,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_COKERNEL_IMAGE_CLOSURE, GeneratorMorphism( Range( morphism ) ) ] ); - lift := Lift( alpha, RelationMorphism( Range( morphism ) ) ); - - if lift = fail then + if not IsLiftable( alpha, RelationMorphism( Range( morphism ) ) ) then return false; @@ -297,15 +321,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_COKERNEL_IMAGE_CLOSURE, AddIsCongruentForMorphisms( category, function( morphism_1, morphism_2 ) - if WitnessForBeingCongruentToZero( SubtractionForMorphisms( morphism_1, morphism_2 ) ) = fail then - - return false; - - else - - return true; - - fi; + return MereExistenceOfWitnessForBeingCongruentToZero( SubtractionForMorphisms( morphism_1, morphism_2 ) ); end ); diff --git a/FreydCategoriesForCAP/gap/FreydCategoriesDerivedMethods.gi b/FreydCategoriesForCAP/gap/FreydCategoriesDerivedMethods.gi index 0292895846..4b8ced10d6 100644 --- a/FreydCategoriesForCAP/gap/FreydCategoriesDerivedMethods.gi +++ b/FreydCategoriesForCAP/gap/FreydCategoriesDerivedMethods.gi @@ -14,7 +14,6 @@ AddDerivationToCAP( ProjectionInSecondFactorOfWeakBiFiberProduct, first_projection := ProjectionInFirstFactorOfWeakBiFiberProduct( cat, alpha, beta ); - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Lift( cat, PreCompose( cat, first_projection, alpha ), beta ); end : Description := "ProjectionInSecondFactorOfWeakBiFiberProduct using ProjectionInFirstFactorOfWeakBiFiberProduct and Lift" ); @@ -27,7 +26,6 @@ AddDerivationToCAP( ProjectionInFirstFactorOfWeakBiFiberProduct, second_projection := ProjectionInSecondFactorOfWeakBiFiberProduct( cat, alpha, beta ); - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Lift( cat, PreCompose( cat, second_projection, beta ), alpha ); end : Description := "ProjectionInFirstFactorOfWeakBiFiberProduct using ProjectionInSecondFactorOfWeakBiFiberProduct and Lift" ); @@ -40,7 +38,6 @@ AddDerivationToCAP( InjectionOfSecondCofactorOfWeakBiPushout, first_injection := InjectionOfFirstCofactorOfWeakBiPushout( cat, alpha, beta ); - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Colift( cat, beta, PreCompose( cat, alpha, first_injection ) ); end : Description := "InjectionOfSecondCofactorOfWeakBiPushout using InjectionOfFirstCofactorOfWeakBiPushout and Colift" ); @@ -53,7 +50,6 @@ AddDerivationToCAP( InjectionOfFirstCofactorOfWeakBiPushout, second_injection := InjectionOfSecondCofactorOfWeakBiPushout( cat, alpha, beta ); - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Colift( cat, alpha, PreCompose( cat, beta, second_injection ) ); end : Description := "InjectionOfFirstCofactorOfWeakBiPushout using InjectionOfSecondCofactorOfWeakBiPushout and Colift" ); @@ -68,7 +64,6 @@ AddDerivationToCAP( UniversalMorphismIntoWeakBiFiberProduct, projection_2 := ProjectionInSecondFactorOfWeakBiFiberProduct( cat, alpha, beta ); - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Lift( cat, UniversalMorphismIntoDirectSum( cat, [ test_mor_1, test_mor_2 ] ), UniversalMorphismIntoDirectSum( cat, [ projection_1, projection_2 ] ) ); @@ -79,7 +74,6 @@ AddDerivationToCAP( UniversalMorphismIntoBiasedWeakFiberProduct, function( cat, alpha, beta, test_mor ) - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Lift( cat, test_mor, ProjectionOfBiasedWeakFiberProduct( cat, alpha, beta ) ); @@ -97,7 +91,6 @@ AddDerivationToCAP( UniversalMorphismFromWeakBiPushout, injection_2 := InjectionOfSecondCofactorOfWeakBiPushout( cat, alpha, beta ); - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Colift( cat, UniversalMorphismFromDirectSum( cat, [ injection_1, injection_2 ] ), UniversalMorphismFromDirectSum( cat, [ test_mor_1, test_mor_2 ] ) ); @@ -108,7 +101,6 @@ AddDerivationToCAP( UniversalMorphismFromBiasedWeakPushout, function( cat, alpha, beta, test_mor ) - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Colift( cat, InjectionOfBiasedWeakPushout( cat, alpha, beta ), test_mor ); @@ -120,7 +112,6 @@ AddDerivationToCAP( WeakKernelLift, function( cat, mor, test_mor ) - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Lift( cat, test_mor, WeakKernelEmbedding( cat, mor ) ); end : Description := "WeakKernelLift as Lift of WeakKernelEmbedding" ); @@ -130,7 +121,6 @@ AddDerivationToCAP( WeakCokernelColift, function( cat, mor, test_mor ) - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Colift( cat, WeakCokernelProjection( cat, mor ), test_mor ); end : Description := "WeakCokernelColift as Colift of WeakCokernelProjection" ); diff --git a/FreydCategoriesForCAP/gap/FreydCategory.gi b/FreydCategoriesForCAP/gap/FreydCategory.gi index 43c7dcabff..ca5d856f2b 100644 --- a/FreydCategoriesForCAP/gap/FreydCategory.gi +++ b/FreydCategoriesForCAP/gap/FreydCategory.gi @@ -296,7 +296,6 @@ InstallMethod( WitnessForBeingCongruentToZero, function( morphism ) #% CAP_JIT_RESOLVE_FUNCTION - #% CAP_JIT_NEXT_FUNCCALL_DOES_NOT_RETURN_FAIL return Lift( UnderlyingCategory( CapCategory( morphism ) ), MorphismDatum( morphism ), RelationMorphism( Range( morphism ) ) ); end ); diff --git a/GradedModulePresentationsForCAP/PackageInfo.g b/GradedModulePresentationsForCAP/PackageInfo.g index f555d2c2f0..7fa19efd30 100644 --- a/GradedModulePresentationsForCAP/PackageInfo.g +++ b/GradedModulePresentationsForCAP/PackageInfo.g @@ -18,7 +18,7 @@ Version := Maximum( [ ## "2019.04-03", # Mohamed's version ## - "2021.05-01", # Fabian's version + "2021.06-01", # Fabian's version ## ] ), @@ -82,7 +82,7 @@ PackageDoc := rec( Dependencies := rec( GAP := ">= 4.6", NeededOtherPackages := [ [ "GAPDoc", ">= 1.5" ], - [ "CAP", ">= 2021.05-01" ], + [ "CAP", ">= 2021.06-01" ], [ "ModulePresentationsForCAP", ">=2019.08.07" ], [ "GradedRingForHomalg", ">=2019.08.07" ], [ "ComplexesAndFilteredObjectsForCAP", ">=2016.09.19" ], diff --git a/GradedModulePresentationsForCAP/examples/CohP1.g b/GradedModulePresentationsForCAP/examples/CohP1.g index a4656c937c..f8632ef2d1 100644 --- a/GradedModulePresentationsForCAP/examples/CohP1.g +++ b/GradedModulePresentationsForCAP/examples/CohP1.g @@ -15,7 +15,7 @@ S := GradedRing( Q["x,y"] ); Sgrmod := GradedLeftPresentations( S ); #! The category of graded left f.p. modules over Q[x,y] (with weights [ 1, 1 ]) InfoOfInstalledOperationsOfCategory( Sgrmod ); -#! 40 primitive operations were used to derive 179 operations for this category which +#! 40 primitive operations were used to derive 172 operations for this category which #! * IsAbCategory #! * IsMonoidalCategory #! * IsAbelianCategoryWithEnoughProjectives diff --git a/LinearAlgebraForCAP/PackageInfo.g b/LinearAlgebraForCAP/PackageInfo.g index df355892be..4f1e0a9ad8 100644 --- a/LinearAlgebraForCAP/PackageInfo.g +++ b/LinearAlgebraForCAP/PackageInfo.g @@ -19,7 +19,7 @@ Version := Maximum( [ ## this line prevents merge conflicts "2020.04-16", ## Sepp's version ## this line prevents merge conflicts - "2021.05-01", ## Fabian's version + "2021.06-01", ## Fabian's version ## this line prevents merge conflicts "2021.05-02", ## Kamal's version @@ -105,7 +105,7 @@ Dependencies := rec( [ "ToolsForHomalg", ">=2015.09.18" ], [ "MatricesForHomalg", ">= 2021.04-04" ], [ "GaussForHomalg", ">= 2021.04-02" ], - [ "CAP", ">= 2021.05-04" ], + [ "CAP", ">= 2021.06-01" ], [ "MonoidalCategories", ">= 2021.03-01" ], ], SuggestedOtherPackages := [ ], diff --git a/LinearAlgebraForCAP/gap/LinearAlgebraForCAP.gi b/LinearAlgebraForCAP/gap/LinearAlgebraForCAP.gi index 69cf805e17..c0a55453a6 100644 --- a/LinearAlgebraForCAP/gap/LinearAlgebraForCAP.gi +++ b/LinearAlgebraForCAP/gap/LinearAlgebraForCAP.gi @@ -497,6 +497,19 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_MATRIX_CATEGORY, ## AddLift( category, + function( cat, alpha, beta ) + local right_divide; + + right_divide := RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ); + + return VectorSpaceMorphism( Source( alpha ), + right_divide, + Source( beta ) ); + + end ); + + ## + AddLiftOrFail( category, function( cat, alpha, beta ) local right_divide; @@ -514,6 +527,14 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_MATRIX_CATEGORY, end ); + ## + AddIsLiftable( category, + function( cat, alpha, beta ) + + return IsZero( DecideZeroRows( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); + + end ); + ## AddCokernelObject( category, function( cat, morphism ) @@ -540,6 +561,19 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_MATRIX_CATEGORY, ## AddColift( category, + function( cat, alpha, beta ) + local left_divide; + + left_divide := LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ); + + return VectorSpaceMorphism( Range( alpha ), + left_divide, + Range( beta ) ); + + end ); + + ## + AddColiftOrFail( category, function( cat, alpha, beta ) local left_divide; @@ -557,6 +591,14 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_MATRIX_CATEGORY, end ); + ## + AddIsColiftable( category, + function( cat, alpha, beta ) + + return IsZero( DecideZeroColumns( UnderlyingMatrix( beta ), UnderlyingMatrix( alpha ) ) ); + + end ); + ## Basic Operation Properties ## AddIsZeroForObjects( category, diff --git a/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi b/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi index 995c770827..c48fbbc854 100644 --- a/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi +++ b/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi @@ -132,13 +132,8 @@ end ######## function ( cat, alpha, beta ) - if LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) = fail then - return fail; - else - return ObjectifyWithAttributes( rec( - ), MorphismType( cat ), CapCategory, cat, Source, Range( alpha ), Range, Range( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); - fi; - return; + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( alpha ), Range, Range( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); end ######## @@ -321,13 +316,7 @@ end ######## function ( cat, alpha, beta ) - if LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) = fail then - return IsCapCategoryMorphism( fail ); - else - return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( - ), MorphismType( cat ), CapCategory, cat, Source, Range( alpha ), Range, Range( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ) ); - fi; - return; + return IsZero( DecideZeroColumns( UnderlyingMatrix( beta ), UnderlyingMatrix( alpha ) ) ); end ######## @@ -338,13 +327,7 @@ end ######## function ( cat, epsilon, tau ) - if LeftDivide( UnderlyingMatrix( epsilon ), UnderlyingMatrix( tau ) ) = fail then - return IsCapCategoryMorphism( fail ); - else - return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( - ), MorphismType( cat ), CapCategory, cat, Source, Range( epsilon ), Range, Range( tau ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( epsilon ), UnderlyingMatrix( tau ) ) ) ); - fi; - return; + return IsZero( DecideZeroColumns( UnderlyingMatrix( tau ), UnderlyingMatrix( epsilon ) ) ); end ######## @@ -476,13 +459,7 @@ end ######## function ( cat, alpha, beta ) - if RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) = fail then - return IsCapCategoryMorphism( fail ); - else - return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( - ), MorphismType( cat ), CapCategory, cat, Source, Source( alpha ), Range, Source( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ) ); - fi; - return; + return IsZero( DecideZeroRows( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); end ######## @@ -493,13 +470,7 @@ end ######## function ( cat, iota, tau ) - if RightDivide( UnderlyingMatrix( tau ), UnderlyingMatrix( iota ) ) = fail then - return IsCapCategoryMorphism( fail ); - else - return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( - ), MorphismType( cat ), CapCategory, cat, Source, Source( tau ), Range, Source( iota ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( UnderlyingMatrix( tau ), UnderlyingMatrix( iota ) ) ) ); - fi; - return; + return IsZero( DecideZeroRows( UnderlyingMatrix( tau ), UnderlyingMatrix( iota ) ) ); end ######## @@ -543,13 +514,7 @@ end ######## function ( cat, morphism ) - if RightDivide( HomalgIdentityMatrix( Dimension( Range( morphism ) ), UnderlyingRing( cat ) ), UnderlyingMatrix( morphism ) ) = fail then - return false; - else - return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( - ), MorphismType( cat ), CapCategory, cat, Source, Range( morphism ), Range, Source( morphism ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( HomalgIdentityMatrix( Dimension( Range( morphism ) ), UnderlyingRing( cat ) ), UnderlyingMatrix( morphism ) ) ) ); - fi; - return; + return IsZero( DecideZeroRows( HomalgIdentityMatrix( Dimension( Range( morphism ) ), UnderlyingRing( cat ) ), UnderlyingMatrix( morphism ) ) ); end ######## @@ -560,13 +525,7 @@ end ######## function ( cat, morphism ) - if LeftDivide( UnderlyingMatrix( morphism ), HomalgIdentityMatrix( Dimension( Source( morphism ) ), UnderlyingRing( cat ) ) ) = fail then - return false; - else - return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( - ), MorphismType( cat ), CapCategory, cat, Source, Range( morphism ), Range, Source( morphism ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( morphism ), HomalgIdentityMatrix( Dimension( Source( morphism ) ), UnderlyingRing( cat ) ) ) ) ); - fi; - return; + return IsZero( DecideZeroColumns( HomalgIdentityMatrix( Dimension( Source( morphism ) ), UnderlyingRing( cat ) ), UnderlyingMatrix( morphism ) ) ); end ######## @@ -717,13 +676,8 @@ end ######## function ( cat, alpha, beta ) - if RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) = fail then - return fail; - else - return ObjectifyWithAttributes( rec( - ), MorphismType( cat ), CapCategory, cat, Source, Source( alpha ), Range, Source( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); - fi; - return; + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( alpha ), Range, Source( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); end ######## diff --git a/LinearAlgebraForCAP/gap/precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi b/LinearAlgebraForCAP/gap/precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi index 3f51995818..9342504051 100644 --- a/LinearAlgebraForCAP/gap/precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi +++ b/LinearAlgebraForCAP/gap/precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi @@ -95,6 +95,21 @@ end ); + ## + AddColift( cat, + +######## +function ( cat, alpha, beta ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Opposite, Source( Opposite( alpha ) ) ), Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Opposite, Source( Opposite( beta ) ) ), Opposite, ObjectifyWithAttributes( rec( + ), MorphismType( Opposite( cat ) ), CapCategory, Opposite( cat ), Source, Source( Opposite( beta ) ), Range, Source( Opposite( alpha ) ), UnderlyingFieldForHomalg, UnderlyingRing( Opposite( cat ) ), UnderlyingMatrix, RightDivide( UnderlyingMatrix( Opposite( beta ) ), UnderlyingMatrix( Opposite( alpha ) ) ) ) ); +end +######## + + ); + ## AddDirectSum( cat, @@ -102,8 +117,8 @@ end function ( cat, arg2 ) return ObjectifyWithAttributes( rec( ), ObjectType( cat ), CapCategory, cat, Opposite, ObjectifyWithAttributes( rec( - ), ObjectType( Opposite( cat ) ), CapCategory, Opposite( cat ), Dimension, Sum( List( arg2, function ( logic_new_func_20684_x ) - return Dimension( Opposite( logic_new_func_20684_x ) ); + ), ObjectType( Opposite( cat ) ), CapCategory, Opposite( cat ), Dimension, Sum( List( arg2, function ( logic_new_func_20771_x ) + return Dimension( Opposite( logic_new_func_20771_x ) ); end ) ), UnderlyingFieldForHomalg, UnderlyingRing( Opposite( cat ) ) ) ); end ######## @@ -197,6 +212,17 @@ end ); + ## + AddIsColiftable( cat, + +######## +function ( cat, arg2, arg3 ) + return IsZero( DecideZeroRows( UnderlyingMatrix( Opposite( arg3 ) ), UnderlyingMatrix( Opposite( arg2 ) ) ) ); +end +######## + + ); + ## AddIsCongruentForMorphisms( cat, @@ -274,6 +300,17 @@ end ); + ## + AddIsLiftable( cat, + +######## +function ( cat, arg2, arg3 ) + return IsZero( DecideZeroColumns( UnderlyingMatrix( Opposite( arg2 ) ), UnderlyingMatrix( Opposite( arg3 ) ) ) ); +end +######## + + ); + ## AddIsMonomorphism( cat, @@ -398,6 +435,21 @@ end ); + ## + AddLift( cat, + +######## +function ( cat, alpha, beta ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Opposite, Range( Opposite( alpha ) ) ), Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Opposite, Range( Opposite( beta ) ) ), Opposite, ObjectifyWithAttributes( rec( + ), MorphismType( Opposite( cat ) ), CapCategory, Opposite( cat ), Source, Range( Opposite( beta ) ), Range, Range( Opposite( alpha ) ), UnderlyingFieldForHomalg, UnderlyingRing( Opposite( cat ) ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( Opposite( beta ) ), UnderlyingMatrix( Opposite( alpha ) ) ) ) ); +end +######## + + ); + ## AddMonomorphismIntoSomeInjectiveObject( cat, @@ -480,8 +532,8 @@ function ( cat, objects, T, tau, P ) ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( ), ObjectType( cat ), CapCategory, cat, Opposite, Opposite( P ) ), Range, ObjectifyWithAttributes( rec( ), ObjectType( cat ), CapCategory, cat, Opposite, Opposite( T ) ), Opposite, ObjectifyWithAttributes( rec( - ), MorphismType( Opposite( cat ) ), CapCategory, Opposite( cat ), Source, Opposite( T ), Range, Opposite( P ), UnderlyingFieldForHomalg, UnderlyingRing( Opposite( cat ) ), UnderlyingMatrix, UnionOfColumns( UnderlyingRing( Opposite( cat ) ), Dimension( Opposite( T ) ), List( tau, function ( logic_new_func_22271_x ) - return UnderlyingMatrix( Opposite( logic_new_func_22271_x ) ); + ), MorphismType( Opposite( cat ) ), CapCategory, Opposite( cat ), Source, Opposite( T ), Range, Opposite( P ), UnderlyingFieldForHomalg, UnderlyingRing( Opposite( cat ) ), UnderlyingMatrix, UnionOfColumns( UnderlyingRing( Opposite( cat ) ), Dimension( Opposite( T ) ), List( tau, function ( logic_new_func_22525_x ) + return UnderlyingMatrix( Opposite( logic_new_func_22525_x ) ); end ) ) ) ); end ######## @@ -512,8 +564,8 @@ function ( cat, objects, T, tau, P ) ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( ), ObjectType( cat ), CapCategory, cat, Opposite, Opposite( T ) ), Range, ObjectifyWithAttributes( rec( ), ObjectType( cat ), CapCategory, cat, Opposite, Opposite( P ) ), Opposite, ObjectifyWithAttributes( rec( - ), MorphismType( Opposite( cat ) ), CapCategory, Opposite( cat ), Source, Opposite( P ), Range, Opposite( T ), UnderlyingFieldForHomalg, UnderlyingRing( Opposite( cat ) ), UnderlyingMatrix, UnionOfRows( UnderlyingRing( Opposite( cat ) ), Dimension( Opposite( T ) ), List( tau, function ( logic_new_func_22436_x ) - return UnderlyingMatrix( Opposite( logic_new_func_22436_x ) ); + ), MorphismType( Opposite( cat ) ), CapCategory, Opposite( cat ), Source, Opposite( P ), Range, Opposite( T ), UnderlyingFieldForHomalg, UnderlyingRing( Opposite( cat ) ), UnderlyingMatrix, UnionOfRows( UnderlyingRing( Opposite( cat ) ), Dimension( Opposite( T ) ), List( tau, function ( logic_new_func_22690_x ) + return UnderlyingMatrix( Opposite( logic_new_func_22690_x ) ); end ) ) ) ); end ######## diff --git a/ModulePresentationsForCAP/PackageInfo.g b/ModulePresentationsForCAP/PackageInfo.g index 018b1f8c80..a49ac74059 100644 --- a/ModulePresentationsForCAP/PackageInfo.g +++ b/ModulePresentationsForCAP/PackageInfo.g @@ -10,7 +10,7 @@ Version := Maximum( [ ## "2019.01-16", # Mohamed's version ## - "2021.05-01", # Fabian's version + "2021.06-01", # Fabian's version ## ] ), @@ -92,7 +92,7 @@ Dependencies := rec( GAP := ">= 4.6", NeededOtherPackages := [ [ "GAPDoc", ">= 1.5" ], [ "MatricesForHomalg", ">=2019.02.01" ], - [ "CAP", ">= 2021.05-01" ], + [ "CAP", ">= 2021.06-01" ], [ "MonoidalCategories", ">= 2019.01.16" ], [ "GeneralizedMorphismsForCAP", ">=0" ], ], diff --git a/ModulePresentationsForCAP/gap/ModulePresentationsForCAP.gi b/ModulePresentationsForCAP/gap/ModulePresentationsForCAP.gi index bf850cb4ab..01e5d3b1ab 100644 --- a/ModulePresentationsForCAP/gap/ModulePresentationsForCAP.gi +++ b/ModulePresentationsForCAP/gap/ModulePresentationsForCAP.gi @@ -1738,14 +1738,12 @@ end ); InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT, function( category ) - local homalg_ring; + local homalg_ring, lift_via_compiled_linear_system_func, colift_via_compiled_linear_system_func; homalg_ring := category!.ring_for_representation_category; - AddLift( category, - - function( morphism_1, morphism_2 ) - local P, N, M, A, B, B_tr_I, N_tr_I, zero_1, mat1, mat2, I_P, zero_2, M_tr_I, mat, vec_A, vec_zero, vec, sol, v, s, XX; + lift_via_compiled_linear_system_func := function( morphism_1, morphism_2 ) + local P, N, M, A, B, 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 # | @@ -1818,30 +1816,72 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT, vec := UnionOfRows( vec_A, vec_zero ); - sol := LeftDivide( mat, vec ); + return [ mat, vec ]; - if sol = fail then + end; + + AddLift( category, function( morphism_1, morphism_2 ) + local P, M, v, s, sol, XX; - return fail; - + P := UnderlyingMatrix( Source( morphism_1 ) ); + + M := UnderlyingMatrix( Source( morphism_2 ) ); + + v := NrColumns( M ); + + s := NrColumns( P ); + + sol := CallFuncList( LeftDivide, lift_via_compiled_linear_system_func( morphism_1, morphism_2 ) ); + + if v <= 1 then + XX := CertainRows( sol, [ 1.. s ] ); else - - 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; - - return PresentationMorphism( Source( morphism_1 ), XX, Source( morphism_2 ) ); - + XX := UnionOfColumns( List( [ 1 .. v ], i-> CertainRows( sol, [ (i-1)*s+1.. i*s ] ) ) ); fi; - end ); + return PresentationMorphism( Source( morphism_1 ), XX, Source( morphism_2 ) ); + + end ); - AddColift( category, + AddLiftOrFail( category, function( morphism_1, morphism_2 ) + local P, M, v, s, sol, XX; - function( morphism_1, morphism_2 ) - local N, M, A, B, I, B_over_M, mat1, mat2, mat, zero_mat, A_over_zero, vec, sol, v, s, XX; + P := UnderlyingMatrix( Source( morphism_1 ) ); + + M := UnderlyingMatrix( Source( morphism_2 ) ); + + v := NrColumns( M ); + + s := NrColumns( P ); + + sol := CallFuncList( LeftDivide, lift_via_compiled_linear_system_func( morphism_1, morphism_2 ) ); + + if sol = fail then + + return fail; + + else + + 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; + + return PresentationMorphism( Source( morphism_1 ), XX, Source( morphism_2 ) ); + + fi; + + end ); + + AddIsLiftable( category, function( morphism_1, morphism_2 ) + + return IsZero( CallFuncList( DecideZeroColumns, Reversed( lift_via_compiled_linear_system_func( morphism_1, morphism_2 ) ) ) ); + + end ); + + colift_via_compiled_linear_system_func := function( morphism_1, morphism_2 ) + local N, M, A, B, I, B_over_M, mat1, mat2, mat, zero_mat, A_over_zero, vec, v, s; # rxs # I # ꓥ @@ -1901,45 +1941,91 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT, vec := UnionOfRows( List( [ 1 .. NrColumns( A ) ], i-> CertainColumns( A_over_zero, [ i ] ) ) ); fi; - sol := LeftDivide( mat, vec ); + return [ mat, vec ]; - if sol = fail then + end; + + AddColift( category, function( morphism_1, morphism_2 ) + local I, M, v, s, sol, XX; - return fail; - - else + I := UnderlyingMatrix( Range( 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; - - return PresentationMorphism( Range( morphism_1 ), XX, Range( morphism_2 ) ); - + M := UnderlyingMatrix( Range( morphism_1 ) ); + + v := NrColumns( M ); + + s := NrColumns( I ); + + 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; - end, 1000 ); - + return PresentationMorphism( Range( morphism_1 ), XX, Range( morphism_2 ) ); + + end, 1000 ); + + AddColiftOrFail( category, function( morphism_1, morphism_2 ) + local I, M, v, s, sol, XX; + + I := UnderlyingMatrix( Range( morphism_2 ) ); + + M := UnderlyingMatrix( Range( morphism_1 ) ); + + v := NrColumns( M ); + + s := NrColumns( I ); + + sol := CallFuncList( LeftDivide, colift_via_compiled_linear_system_func( morphism_1, morphism_2 ) ); + + if sol = fail then + + return fail; + + else + + 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; + + return PresentationMorphism( Range( morphism_1 ), XX, Range( morphism_2 ) ); + + fi; + + end, 1000 ); + + AddIsColiftable( category, function( morphism_1, morphism_2 ) + + return IsZero( CallFuncList( DecideZeroColumns, Reversed( colift_via_compiled_linear_system_func( morphism_1, morphism_2 ) ) ) ); + + end, 1000 ); + end ); ## InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT, function( category ) - local homalg_ring; + local homalg_ring, lift_via_compiled_linear_system_func, colift_via_compiled_linear_system_func; homalg_ring := category!.ring_for_representation_category; - AddLift( category, - - function( morphism_1, morphism_2 ) + 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, - mat1, mat2, I_P, zero_2, M_tr_I, mat, vec_A, vec_zero, vec, sol, v, s, XX; + mat1, mat2, I_P, zero_2, M_tr_I, mat, vec_A, vec_zero, vec, v, s; # rxs # P # | @@ -2016,30 +2102,70 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT, vec := UnionOfRows( vec_A, vec_zero ); - sol := LeftDivide( mat, vec ); + return [ mat, vec ]; - if sol = fail then + end; + + AddLift( category, function( morphism_1, morphism_2 ) + local Pt, Mt, v, s, sol, XX; - return fail; - - else - - 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; - - return PresentationMorphism( Source( morphism_1 ), XX, Source( morphism_2 ) ); - + Pt := TransposedMatrix( UnderlyingMatrix( Source( morphism_1 ) ) ); + Mt := TransposedMatrix( UnderlyingMatrix( Source( morphism_2 ) ) ); + + v := NrColumns( Mt ); + + s := NrColumns( Pt ); + + 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; -end ); - - AddColift( category, + return PresentationMorphism( Source( morphism_1 ), XX, Source( morphism_2 ) ); - function( morphism_1, morphism_2 ) - local Nt, Mt, At, Bt, It, B_over_M, mat1, mat2, mat, zero_mat, A_over_zero, vec, sol, v, s, XX; + end ); + + AddLiftOrFail( category, function( morphism_1, morphism_2 ) + local Pt, Mt, v, s, sol, XX; + + Pt := TransposedMatrix( UnderlyingMatrix( Source( morphism_1 ) ) ); + Mt := TransposedMatrix( UnderlyingMatrix( Source( morphism_2 ) ) ); + + v := NrColumns( Mt ); + + s := NrColumns( Pt ); + + sol := CallFuncList( LeftDivide, lift_via_compiled_linear_system_func( morphism_1, morphism_2 ) ); + + if sol = fail then + + return fail; + + else + + 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; + + return PresentationMorphism( Source( morphism_1 ), XX, Source( morphism_2 ) ); + + fi; + + end ); + + AddIsLiftable( category, function( morphism_1, morphism_2 ) + + return IsZero( CallFuncList( DecideZeroColumns, Reversed( lift_via_compiled_linear_system_func( morphism_1, morphism_2 ) ) ) ); + + end ); + + colift_via_compiled_linear_system_func := function( morphism_1, morphism_2 ) + local Nt, Mt, At, Bt, It, B_over_M, mat1, mat2, mat, zero_mat, A_over_zero, vec, v, s; It := TransposedMatrix( UnderlyingMatrix( Range( morphism_2 ) ) ); @@ -2081,30 +2207,78 @@ end ); vec := UnionOfRows( List( [ 1 .. NrColumns( At ) ], i-> CertainColumns( A_over_zero, [ i ] ) ) ); fi; - sol := LeftDivide( mat, vec ); + return [ mat, vec ]; - if sol = fail then + end; + + AddColift( category, function( morphism_1, morphism_2 ) + local It, Mt, v, s, sol, XX; - return fail; - - else + It := TransposedMatrix( UnderlyingMatrix( Range( 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; - - return PresentationMorphism( Range( morphism_1 ), XX, Range( morphism_2 ) ); - + Mt := TransposedMatrix( UnderlyingMatrix( Range( morphism_1 ) ) ); + + v := NrColumns( Mt ); + + s := NrColumns( It ); + + 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; - end, 1000 ); - + return PresentationMorphism( Range( morphism_1 ), XX, Range( morphism_2 ) ); + + end, 1000 ); + + AddColiftOrFail( category, function( morphism_1, morphism_2 ) + local It, Mt, v, s, sol, XX; + + It := TransposedMatrix( UnderlyingMatrix( Range( morphism_2 ) ) ); + + Mt := TransposedMatrix( UnderlyingMatrix( Range( morphism_1 ) ) ); + + v := NrColumns( Mt ); + + s := NrColumns( It ); + + sol := CallFuncList( LeftDivide, colift_via_compiled_linear_system_func( morphism_1, morphism_2 ) ); + + if sol = fail then + + return fail; + + else + + 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; + + return PresentationMorphism( Range( morphism_1 ), XX, Range( morphism_2 ) ); + + fi; + + end, 1000 ); + + AddIsColiftable( category, function( morphism_1, morphism_2 ) + + return IsZero( CallFuncList( DecideZeroColumns, Reversed( colift_via_compiled_linear_system_func( morphism_1, morphism_2 ) ) ) ); + + end, 1000 ); + end ); ##