From f8a149bc7d426d97df600652f0b25a0612f46171 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Tue, 20 Sep 2022 16:40:35 +0200 Subject: [PATCH] Simplify `List( list, func )[index]` to `func( list[index] )` in post-processing --- CompilerForCAP/PackageInfo.g | 2 +- .../examples/CapJitDisableDataTypeInference.g | 22 +- CompilerForCAP/gap/CompilerForCAP.gi | 69 ++++- LinearAlgebraForCAP/PackageInfo.g | 2 +- .../MatrixCategoryPrecompiled.gi | 256 +++++++++--------- .../OppositeOfMatrixCategoryPrecompiled.gi | 40 ++- 6 files changed, 239 insertions(+), 152 deletions(-) diff --git a/CompilerForCAP/PackageInfo.g b/CompilerForCAP/PackageInfo.g index 2a2c0d32cc..1af26c23c0 100644 --- a/CompilerForCAP/PackageInfo.g +++ b/CompilerForCAP/PackageInfo.g @@ -10,7 +10,7 @@ SetPackageInfo( rec( PackageName := "CompilerForCAP", Subtitle := "Speed up computations in CAP categories", -Version := "2022.09-07", +Version := "2022.09-08", Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ), License := "GPL-2.0-or-later", diff --git a/CompilerForCAP/examples/CapJitDisableDataTypeInference.g b/CompilerForCAP/examples/CapJitDisableDataTypeInference.g index 03bfaffece..03bfd24e16 100644 --- a/CompilerForCAP/examples/CapJitDisableDataTypeInference.g +++ b/CompilerForCAP/examples/CapJitDisableDataTypeInference.g @@ -7,9 +7,15 @@ LoadPackage( "CompilerForCAP", false ); #! true -func := list -> Sum( list[1] );; +func := { list1, list2 } -> List( list1, x -> Sum( list2[x] ) );; type_signature := [ [ + rec( + filter := IsList, + element_type := rec( + filter := IsInt, + ), + ), rec( filter := IsList, element_type := rec( @@ -26,15 +32,21 @@ type_signature := [ CapJitDisableDataTypeInference( ); Display( CapJitCompiledFunction( func, type_signature ) ); -#! function ( list_1 ) -#! return Sum( list_1[1] ); +#! function ( list1_1, list2_1 ) +#! return List( list1_1, function ( x_2 ) +#! return Sum( list2_1[x_2] ); +#! end ); #! end CapJitEnableDataTypeInference( ); Display( CapJitCompiledFunction( func, type_signature ) ); -#! function ( list_1 ) -#! return List( list_1, Sum )[1]; +#! function ( list1_1, list2_1 ) +#! local hoisted_3_1; +#! hoisted_3_1 := List( list2_1, Sum ); +#! return List( list1_1, function ( x_2 ) +#! return hoisted_3_1[x_2]; +#! end ); #! end #! @EndExample diff --git a/CompilerForCAP/gap/CompilerForCAP.gi b/CompilerForCAP/gap/CompilerForCAP.gi index ffe5bb8838..a44a0abedf 100644 --- a/CompilerForCAP/gap/CompilerForCAP.gi +++ b/CompilerForCAP/gap/CompilerForCAP.gi @@ -398,7 +398,7 @@ InstallGlobalFunction( CapJitCompiledFunctionAsEnhancedSyntaxTree, function ( fu end ); InstallGlobalFunction( CAP_JIT_INTERNAL_POST_PROCESSED_SYNTAX_TREE, function ( tree, category, debug ) - local compiled_func; + local compiled_func, changed, pre_func; if debug then # COVERAGE_IGNORE_BLOCK_START @@ -447,6 +447,73 @@ InstallGlobalFunction( CAP_JIT_INTERNAL_POST_PROCESSED_SYNTAX_TREE, function ( t tree := CapJitDeduplicatedExpressions( tree ); + # Simplify `List( list, func )[index]` to `func( list[index] )`. + # We do not want to do this during compilation because of the following situation: + # expr1 := List( [ 1 .. var1 ], x -> very_expensive_operation( x ) ); expr2 := List( [ 1 .. var2 ], y -> List( [ 1 .. var1 ], x -> expr1[x][y] ) ); + # If we inline and transform this to + # expr2 := List( [ 1 .. var2 ], y -> List( [ 1 .. var1 ], x -> very_expensive_operation( x )[y] ) ); + # we cannot simply hoist `very_expensive_operation( x )`. One solution would be "generalized hoisting": We can detect that the subexpression + # `very_expensive_operation( x )` and its domain `[ 1 .. var1 ]` are independent of `y` and thus extract `expr1` from `expr2` again. + # However, this only improves the runtime if looping over `[ 1 .. var1 ]` is less expensive than the additional computations of `very_expensive_operation( x )` + # in the inlined expression. CompilerForCAP cannot decide this. + # Another solution would be to only transform `List( list, func )[index]` if `List( list, func )` depends on the same function levels as `index` and can thus not + # be hoisted anyway. However, the function levels on which `List( list, func )` depends can change during the compilation due to cancellation. + # Thus, we use the brute-force algorithm here: If we encounter `List( list, func )[index]` during post-processing and after inlining and hoisting, + # simplifying it to `func( list[index] )` always makes sense. This simplification might lead to new instances of `List( list, func )[index]`, + # so we repeat the process until no occurrences of `List( list, func )[index]` remain. In principle, we should rerun the whole rule phase, but this would require + # type signatures and can thus not be triggered from the post-processing currently. As a consequence, one cannot apply logic to the result of this simplifcation. + while true do + + changed := false; + + pre_func := function ( tree, additional_arguments ) + + if CapJitIsCallToGlobalFunction( tree, "[]" ) and CapJitIsCallToGlobalFunction( tree.args.1, "List" ) and tree.args.1.args.length = 2 then + + changed := true; + + # func( list[index] ) + return rec( + type := "EXPR_FUNCCALL", + funcref := tree.args.1.args.2, # func + args := AsSyntaxTreeList( [ + rec( + type := "EXPR_FUNCCALL", + funcref := rec( + type := "EXPR_REF_GVAR", + gvar := "[]", + ), + args := AsSyntaxTreeList( [ + tree.args.1.args.1, # list + tree.args.2, # index + ] ), + ), + ] ), + ); + + fi; + + return tree; + + end; + + tree := CapJitIterateOverTree( tree, pre_func, CapJitResultFuncCombineChildren, ReturnTrue, true ); + + if not changed then + + break; + + fi; + + tree := CapJitInlinedArguments( tree ); + tree := CapJitInlinedSimpleFunctionCalls( tree ); + tree := CapJitInlinedFunctionCalls( tree ); + tree := CapJitInlinedBindingsFully( tree ); + tree := CapJitHoistedExpressions( tree ); + tree := CapJitDeduplicatedExpressions( tree ); + + od; + fi; return tree; diff --git a/LinearAlgebraForCAP/PackageInfo.g b/LinearAlgebraForCAP/PackageInfo.g index e015c7bc73..67874f7589 100644 --- a/LinearAlgebraForCAP/PackageInfo.g +++ b/LinearAlgebraForCAP/PackageInfo.g @@ -10,7 +10,7 @@ SetPackageInfo( rec( PackageName := "LinearAlgebraForCAP", Subtitle := "Category of Matrices over a Field for CAP", -Version := "2022.09-07", +Version := "2022.09-08", Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ), License := "GPL-2.0-or-later", diff --git a/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi b/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi index 28096724b9..1129c0c048 100644 --- a/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi +++ b/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi @@ -1600,14 +1600,15 @@ end ######## function ( cat_1, objects_1, k_1 ) - local morphism_attr_1_1, deduped_2_1, deduped_3_1, deduped_4_1; - deduped_4_1 := UnderlyingRing( cat_1 ); - deduped_3_1 := List( objects_1, Dimension )[k_1]; + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1, deduped_5_1; + deduped_5_1 := UnderlyingRing( cat_1 ); + deduped_4_1 := objects_1[k_1]; + deduped_3_1 := Dimension( deduped_4_1 ); deduped_2_1 := List( objects_1, function ( c_2 ) return Dimension( c_2 ); end ); - morphism_attr_1_1 := UnionOfColumns( HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_4_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_4_1 ), HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_4_1 ) ); - return CreateCapCategoryMorphismWithAttributes( cat_1, objects_1[k_1], CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( morphism_attr_1_1 ) ), UnderlyingMatrix, morphism_attr_1_1 ); + deduped_1_1 := UnionOfColumns( HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_5_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_5_1 ), HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_5_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, deduped_4_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( deduped_1_1 ) ), UnderlyingMatrix, deduped_1_1 ); end ######## @@ -1618,14 +1619,15 @@ end ######## function ( cat_1, objects_1, k_1, P_1 ) - local morphism_attr_1_1, deduped_2_1, deduped_3_1, deduped_4_1; - deduped_4_1 := UnderlyingRing( cat_1 ); - deduped_3_1 := List( objects_1, Dimension )[k_1]; + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1, deduped_5_1; + deduped_5_1 := UnderlyingRing( cat_1 ); + deduped_4_1 := objects_1[k_1]; + deduped_3_1 := Dimension( deduped_4_1 ); deduped_2_1 := List( objects_1, function ( c_2 ) return Dimension( c_2 ); end ); - morphism_attr_1_1 := UnionOfColumns( HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_4_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_4_1 ), HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_4_1 ) ); - return CreateCapCategoryMorphismWithAttributes( cat_1, objects_1[k_1], CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( morphism_attr_1_1 ) ), UnderlyingMatrix, morphism_attr_1_1 ); + deduped_1_1 := UnionOfColumns( HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_5_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_5_1 ), HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_5_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, deduped_4_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( deduped_1_1 ) ), UnderlyingMatrix, deduped_1_1 ); end ######## @@ -1636,14 +1638,15 @@ end ######## function ( cat_1, objects_1, k_1 ) - local morphism_attr_1_1, deduped_2_1, deduped_3_1, deduped_4_1; - deduped_4_1 := UnderlyingRing( cat_1 ); - deduped_3_1 := List( objects_1, Dimension )[k_1]; + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1, deduped_5_1; + deduped_5_1 := UnderlyingRing( cat_1 ); + deduped_4_1 := objects_1[k_1]; + deduped_3_1 := Dimension( deduped_4_1 ); deduped_2_1 := List( objects_1, function ( c_2 ) return Dimension( c_2 ); end ); - morphism_attr_1_1 := UnionOfColumns( HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_4_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_4_1 ), HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_4_1 ) ); - return CreateCapCategoryMorphismWithAttributes( cat_1, objects_1[k_1], CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( morphism_attr_1_1 ) ), UnderlyingMatrix, morphism_attr_1_1 ); + deduped_1_1 := UnionOfColumns( HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_5_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_5_1 ), HomalgZeroMatrix( deduped_3_1, Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_5_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, deduped_4_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( deduped_1_1 ) ), UnderlyingMatrix, deduped_1_1 ); end ######## @@ -1654,13 +1657,14 @@ end ######## function ( cat_1, objects_1, k_1, P_1 ) - local deduped_1_1, deduped_2_1, deduped_3_1; - deduped_3_1 := UnderlyingRing( cat_1 ); - deduped_2_1 := List( objects_1, Dimension )[k_1]; + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1; + deduped_4_1 := UnderlyingRing( cat_1 ); + deduped_3_1 := objects_1[k_1]; + deduped_2_1 := Dimension( deduped_3_1 ); deduped_1_1 := List( objects_1, function ( c_2 ) return Dimension( c_2 ); end ); - return CreateCapCategoryMorphismWithAttributes( cat_1, objects_1[k_1], P_1, UnderlyingMatrix, UnionOfColumns( HomalgZeroMatrix( deduped_2_1, Sum( deduped_1_1{[ 1 .. k_1 - 1 ]} ), deduped_3_1 ), HomalgIdentityMatrix( deduped_2_1, deduped_3_1 ), HomalgZeroMatrix( deduped_2_1, Sum( deduped_1_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_3_1 ) ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, deduped_3_1, P_1, UnderlyingMatrix, UnionOfColumns( HomalgZeroMatrix( deduped_2_1, Sum( deduped_1_1{[ 1 .. k_1 - 1 ]} ), deduped_4_1 ), HomalgIdentityMatrix( deduped_2_1, deduped_4_1 ), HomalgZeroMatrix( deduped_2_1, Sum( deduped_1_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_4_1 ) ) ); end ######## @@ -1671,7 +1675,7 @@ end ######## function ( cat_1, morphisms_1, k_1 ) - local morphism_attr_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1; + local hoisted_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, deduped_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1; deduped_11_1 := Length( morphisms_1 ); deduped_10_1 := UnderlyingRing( cat_1 ); deduped_9_1 := List( morphisms_1, function ( logic_new_func_x_2 ) @@ -1679,17 +1683,17 @@ function ( cat_1, morphisms_1, k_1 ) end ); deduped_8_1 := Sum( deduped_9_1 ); deduped_7_1 := Sum( deduped_9_1{[ 1 .. k_1 - 1 ]} ) + 1; - hoisted_5_1 := deduped_11_1; - hoisted_4_1 := deduped_10_1; - hoisted_3_1 := deduped_9_1; - hoisted_2_1 := List( morphisms_1, UnderlyingMatrix ); + hoisted_4_1 := deduped_11_1; + hoisted_3_1 := deduped_10_1; + hoisted_2_1 := deduped_9_1; + hoisted_1_1 := List( morphisms_1, UnderlyingMatrix ); deduped_6_1 := List( [ 1 .. deduped_11_1 ], function ( logic_new_func_x_2 ) local deduped_1_2; - deduped_1_2 := hoisted_3_1[logic_new_func_x_2]; - return hoisted_2_1[logic_new_func_x_2] * UnionOfColumns( HomalgZeroMatrix( deduped_1_2, Sum( hoisted_3_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), hoisted_4_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_4_1 ), HomalgZeroMatrix( deduped_1_2, Sum( hoisted_3_1{[ (logic_new_func_x_2 + 1) .. hoisted_5_1 ]} ), hoisted_4_1 ) ); + deduped_1_2 := hoisted_2_1[logic_new_func_x_2]; + return hoisted_1_1[logic_new_func_x_2] * UnionOfColumns( HomalgZeroMatrix( deduped_1_2, Sum( hoisted_2_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), hoisted_3_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_3_1 ), HomalgZeroMatrix( deduped_1_2, Sum( hoisted_2_1{[ (logic_new_func_x_2 + 1) .. hoisted_4_1 ]} ), hoisted_3_1 ) ); end ); - morphism_attr_1_1 := CertainRows( SyzygiesOfColumns( UnionOfRows( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfRows( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} ) ), [ deduped_7_1 .. deduped_7_1 - 1 + deduped_9_1[k_1] ] ); - return CreateCapCategoryMorphismWithAttributes( cat_1, List( morphisms_1, Range )[k_1], CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( morphism_attr_1_1 ) ), UnderlyingMatrix, morphism_attr_1_1 ); + deduped_5_1 := CertainRows( SyzygiesOfColumns( UnionOfRows( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfRows( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} ) ), [ deduped_7_1 .. deduped_7_1 - 1 + deduped_9_1[k_1] ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Range( morphisms_1[k_1] ), CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( deduped_5_1 ) ), UnderlyingMatrix, deduped_5_1 ); end ######## @@ -1700,7 +1704,7 @@ end ######## function ( cat_1, morphisms_1, k_1, P_1 ) - local morphism_attr_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1; + local hoisted_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, deduped_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1; deduped_11_1 := Length( morphisms_1 ); deduped_10_1 := UnderlyingRing( cat_1 ); deduped_9_1 := List( morphisms_1, function ( logic_new_func_x_2 ) @@ -1708,17 +1712,17 @@ function ( cat_1, morphisms_1, k_1, P_1 ) end ); deduped_8_1 := Sum( deduped_9_1 ); deduped_7_1 := Sum( deduped_9_1{[ 1 .. k_1 - 1 ]} ) + 1; - hoisted_5_1 := deduped_11_1; - hoisted_4_1 := deduped_10_1; - hoisted_3_1 := deduped_9_1; - hoisted_2_1 := List( morphisms_1, UnderlyingMatrix ); + hoisted_4_1 := deduped_11_1; + hoisted_3_1 := deduped_10_1; + hoisted_2_1 := deduped_9_1; + hoisted_1_1 := List( morphisms_1, UnderlyingMatrix ); deduped_6_1 := List( [ 1 .. deduped_11_1 ], function ( logic_new_func_x_2 ) local deduped_1_2; - deduped_1_2 := hoisted_3_1[logic_new_func_x_2]; - return hoisted_2_1[logic_new_func_x_2] * UnionOfColumns( HomalgZeroMatrix( deduped_1_2, Sum( hoisted_3_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), hoisted_4_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_4_1 ), HomalgZeroMatrix( deduped_1_2, Sum( hoisted_3_1{[ (logic_new_func_x_2 + 1) .. hoisted_5_1 ]} ), hoisted_4_1 ) ); + deduped_1_2 := hoisted_2_1[logic_new_func_x_2]; + return hoisted_1_1[logic_new_func_x_2] * UnionOfColumns( HomalgZeroMatrix( deduped_1_2, Sum( hoisted_2_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), hoisted_3_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_3_1 ), HomalgZeroMatrix( deduped_1_2, Sum( hoisted_2_1{[ (logic_new_func_x_2 + 1) .. hoisted_4_1 ]} ), hoisted_3_1 ) ); end ); - morphism_attr_1_1 := CertainRows( SyzygiesOfColumns( UnionOfRows( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfRows( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} ) ), [ deduped_7_1 .. deduped_7_1 - 1 + deduped_9_1[k_1] ] ); - return CreateCapCategoryMorphismWithAttributes( cat_1, List( morphisms_1, Range )[k_1], CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( morphism_attr_1_1 ) ), UnderlyingMatrix, morphism_attr_1_1 ); + deduped_5_1 := CertainRows( SyzygiesOfColumns( UnionOfRows( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfRows( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} ) ), [ deduped_7_1 .. deduped_7_1 - 1 + deduped_9_1[k_1] ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Range( morphisms_1[k_1] ), CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( deduped_5_1 ) ), UnderlyingMatrix, deduped_5_1 ); end ######## @@ -4051,7 +4055,7 @@ end ######## function ( cat_1, morphisms_1 ) - local morphism_attr_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1, deduped_12_1; + local hoisted_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, deduped_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1, deduped_12_1; deduped_12_1 := List( morphisms_1, UnderlyingMatrix ); deduped_11_1 := Length( morphisms_1 ); deduped_10_1 := UnderlyingRing( cat_1 ); @@ -4060,17 +4064,17 @@ function ( cat_1, morphisms_1 ) end ); deduped_8_1 := Sum( deduped_9_1 ); deduped_7_1 := Sum( deduped_9_1{[ 1 .. 1 - 1 ]} ) + 1; - hoisted_5_1 := deduped_12_1; - hoisted_4_1 := deduped_11_1; - hoisted_3_1 := deduped_10_1; - hoisted_2_1 := deduped_9_1; + hoisted_4_1 := deduped_12_1; + hoisted_3_1 := deduped_11_1; + hoisted_2_1 := deduped_10_1; + hoisted_1_1 := deduped_9_1; deduped_6_1 := List( [ 1 .. deduped_11_1 ], function ( logic_new_func_x_2 ) local deduped_1_2; - deduped_1_2 := hoisted_2_1[logic_new_func_x_2]; - return UnionOfRows( HomalgZeroMatrix( Sum( hoisted_2_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), deduped_1_2, hoisted_3_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_3_1 ), HomalgZeroMatrix( Sum( hoisted_2_1{[ (logic_new_func_x_2 + 1) .. hoisted_4_1 ]} ), deduped_1_2, hoisted_3_1 ) ) * hoisted_5_1[logic_new_func_x_2]; + deduped_1_2 := hoisted_1_1[logic_new_func_x_2]; + return UnionOfRows( HomalgZeroMatrix( Sum( hoisted_1_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), deduped_1_2, hoisted_2_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_2_1 ), HomalgZeroMatrix( Sum( hoisted_1_1{[ (logic_new_func_x_2 + 1) .. hoisted_3_1 ]} ), deduped_1_2, hoisted_2_1 ) ) * hoisted_4_1[logic_new_func_x_2]; end ); - morphism_attr_1_1 := CertainColumns( SyzygiesOfRows( (UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} )) ), [ deduped_7_1 .. (deduped_7_1 - 1 + deduped_9_1[1]) ] ) * deduped_12_1[1]; - return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( morphism_attr_1_1 ) ), List( morphisms_1, Range )[1], UnderlyingMatrix, morphism_attr_1_1 ); + deduped_5_1 := CertainColumns( SyzygiesOfRows( (UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} )) ), [ deduped_7_1 .. (deduped_7_1 - 1 + deduped_9_1[1]) ] ) * deduped_12_1[1]; + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( deduped_5_1 ) ), Range( morphisms_1[1] ), UnderlyingMatrix, deduped_5_1 ); end ######## @@ -4081,7 +4085,7 @@ end ######## function ( cat_1, morphisms_1, P_1 ) - local morphism_attr_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1, deduped_12_1; + local hoisted_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, deduped_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1, deduped_12_1; deduped_12_1 := List( morphisms_1, UnderlyingMatrix ); deduped_11_1 := Length( morphisms_1 ); deduped_10_1 := UnderlyingRing( cat_1 ); @@ -4090,17 +4094,17 @@ function ( cat_1, morphisms_1, P_1 ) end ); deduped_8_1 := Sum( deduped_9_1 ); deduped_7_1 := Sum( deduped_9_1{[ 1 .. 1 - 1 ]} ) + 1; - hoisted_5_1 := deduped_12_1; - hoisted_4_1 := deduped_11_1; - hoisted_3_1 := deduped_10_1; - hoisted_2_1 := deduped_9_1; + hoisted_4_1 := deduped_12_1; + hoisted_3_1 := deduped_11_1; + hoisted_2_1 := deduped_10_1; + hoisted_1_1 := deduped_9_1; deduped_6_1 := List( [ 1 .. deduped_11_1 ], function ( logic_new_func_x_2 ) local deduped_1_2; - deduped_1_2 := hoisted_2_1[logic_new_func_x_2]; - return UnionOfRows( HomalgZeroMatrix( Sum( hoisted_2_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), deduped_1_2, hoisted_3_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_3_1 ), HomalgZeroMatrix( Sum( hoisted_2_1{[ (logic_new_func_x_2 + 1) .. hoisted_4_1 ]} ), deduped_1_2, hoisted_3_1 ) ) * hoisted_5_1[logic_new_func_x_2]; + deduped_1_2 := hoisted_1_1[logic_new_func_x_2]; + return UnionOfRows( HomalgZeroMatrix( Sum( hoisted_1_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), deduped_1_2, hoisted_2_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_2_1 ), HomalgZeroMatrix( Sum( hoisted_1_1{[ (logic_new_func_x_2 + 1) .. hoisted_3_1 ]} ), deduped_1_2, hoisted_2_1 ) ) * hoisted_4_1[logic_new_func_x_2]; end ); - morphism_attr_1_1 := CertainColumns( SyzygiesOfRows( (UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} )) ), [ deduped_7_1 .. (deduped_7_1 - 1 + deduped_9_1[1]) ] ) * deduped_12_1[1]; - return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( morphism_attr_1_1 ) ), List( morphisms_1, Range )[1], UnderlyingMatrix, morphism_attr_1_1 ); + deduped_5_1 := CertainColumns( SyzygiesOfRows( (UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} )) ), [ deduped_7_1 .. (deduped_7_1 - 1 + deduped_9_1[1]) ] ) * deduped_12_1[1]; + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( deduped_5_1 ) ), Range( morphisms_1[1] ), UnderlyingMatrix, deduped_5_1 ); end ######## @@ -4219,7 +4223,7 @@ end ######## function ( cat_1, morphisms_1 ) - local morphism_attr_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1, deduped_12_1; + local hoisted_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, deduped_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1, deduped_12_1; deduped_12_1 := Length( morphisms_1 ); deduped_11_1 := UnderlyingRing( cat_1 ); deduped_10_1 := List( morphisms_1, UnderlyingMatrix ); @@ -4228,17 +4232,17 @@ function ( cat_1, morphisms_1 ) end ); deduped_8_1 := Sum( deduped_9_1 ); deduped_7_1 := Sum( deduped_9_1{[ 1 .. 1 - 1 ]} ) + 1; - hoisted_5_1 := deduped_12_1; - hoisted_4_1 := deduped_11_1; - hoisted_3_1 := deduped_9_1; - hoisted_2_1 := deduped_10_1; + hoisted_4_1 := deduped_12_1; + hoisted_3_1 := deduped_11_1; + hoisted_2_1 := deduped_9_1; + hoisted_1_1 := deduped_10_1; deduped_6_1 := List( [ 1 .. deduped_12_1 ], function ( logic_new_func_x_2 ) local deduped_1_2; - deduped_1_2 := hoisted_3_1[logic_new_func_x_2]; - return hoisted_2_1[logic_new_func_x_2] * UnionOfColumns( HomalgZeroMatrix( deduped_1_2, Sum( hoisted_3_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), hoisted_4_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_4_1 ), HomalgZeroMatrix( deduped_1_2, Sum( hoisted_3_1{[ (logic_new_func_x_2 + 1) .. hoisted_5_1 ]} ), hoisted_4_1 ) ); + deduped_1_2 := hoisted_2_1[logic_new_func_x_2]; + return hoisted_1_1[logic_new_func_x_2] * UnionOfColumns( HomalgZeroMatrix( deduped_1_2, Sum( hoisted_2_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), hoisted_3_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_3_1 ), HomalgZeroMatrix( deduped_1_2, Sum( hoisted_2_1{[ (logic_new_func_x_2 + 1) .. hoisted_4_1 ]} ), hoisted_3_1 ) ); end ); - morphism_attr_1_1 := deduped_10_1[1] * CertainRows( SyzygiesOfColumns( (UnionOfRows( deduped_11_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_12_1 - 1 ]} ) + -1 * UnionOfRows( deduped_11_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_12_1 ]} )) ), [ deduped_7_1 .. (deduped_7_1 - 1 + deduped_9_1[1]) ] ); - return CreateCapCategoryMorphismWithAttributes( cat_1, List( morphisms_1, Source )[1], CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( morphism_attr_1_1 ) ), UnderlyingMatrix, morphism_attr_1_1 ); + deduped_5_1 := deduped_10_1[1] * CertainRows( SyzygiesOfColumns( (UnionOfRows( deduped_11_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_12_1 - 1 ]} ) + -1 * UnionOfRows( deduped_11_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_12_1 ]} )) ), [ deduped_7_1 .. (deduped_7_1 - 1 + deduped_9_1[1]) ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Source( morphisms_1[1] ), CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( deduped_5_1 ) ), UnderlyingMatrix, deduped_5_1 ); end ######## @@ -4249,7 +4253,7 @@ end ######## function ( cat_1, morphisms_1, P_1 ) - local morphism_attr_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1, deduped_12_1; + local hoisted_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, deduped_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1, deduped_12_1; deduped_12_1 := Length( morphisms_1 ); deduped_11_1 := UnderlyingRing( cat_1 ); deduped_10_1 := List( morphisms_1, UnderlyingMatrix ); @@ -4258,17 +4262,17 @@ function ( cat_1, morphisms_1, P_1 ) end ); deduped_8_1 := Sum( deduped_9_1 ); deduped_7_1 := Sum( deduped_9_1{[ 1 .. 1 - 1 ]} ) + 1; - hoisted_5_1 := deduped_12_1; - hoisted_4_1 := deduped_11_1; - hoisted_3_1 := deduped_9_1; - hoisted_2_1 := deduped_10_1; + hoisted_4_1 := deduped_12_1; + hoisted_3_1 := deduped_11_1; + hoisted_2_1 := deduped_9_1; + hoisted_1_1 := deduped_10_1; deduped_6_1 := List( [ 1 .. deduped_12_1 ], function ( logic_new_func_x_2 ) local deduped_1_2; - deduped_1_2 := hoisted_3_1[logic_new_func_x_2]; - return hoisted_2_1[logic_new_func_x_2] * UnionOfColumns( HomalgZeroMatrix( deduped_1_2, Sum( hoisted_3_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), hoisted_4_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_4_1 ), HomalgZeroMatrix( deduped_1_2, Sum( hoisted_3_1{[ (logic_new_func_x_2 + 1) .. hoisted_5_1 ]} ), hoisted_4_1 ) ); + deduped_1_2 := hoisted_2_1[logic_new_func_x_2]; + return hoisted_1_1[logic_new_func_x_2] * UnionOfColumns( HomalgZeroMatrix( deduped_1_2, Sum( hoisted_2_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), hoisted_3_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_3_1 ), HomalgZeroMatrix( deduped_1_2, Sum( hoisted_2_1{[ (logic_new_func_x_2 + 1) .. hoisted_4_1 ]} ), hoisted_3_1 ) ); end ); - morphism_attr_1_1 := deduped_10_1[1] * CertainRows( SyzygiesOfColumns( (UnionOfRows( deduped_11_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_12_1 - 1 ]} ) + -1 * UnionOfRows( deduped_11_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_12_1 ]} )) ), [ deduped_7_1 .. (deduped_7_1 - 1 + deduped_9_1[1]) ] ); - return CreateCapCategoryMorphismWithAttributes( cat_1, List( morphisms_1, Source )[1], CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( morphism_attr_1_1 ) ), UnderlyingMatrix, morphism_attr_1_1 ); + deduped_5_1 := deduped_10_1[1] * CertainRows( SyzygiesOfColumns( (UnionOfRows( deduped_11_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_12_1 - 1 ]} ) + -1 * UnionOfRows( deduped_11_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_12_1 ]} )) ), [ deduped_7_1 .. (deduped_7_1 - 1 + deduped_9_1[1]) ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Source( morphisms_1[1] ), CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( deduped_5_1 ) ), UnderlyingMatrix, deduped_5_1 ); end ######## @@ -4464,14 +4468,15 @@ end ######## function ( cat_1, objects_1, k_1 ) - local morphism_attr_1_1, deduped_2_1, deduped_3_1, deduped_4_1; - deduped_4_1 := UnderlyingRing( cat_1 ); - deduped_3_1 := List( objects_1, Dimension )[k_1]; + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1, deduped_5_1; + deduped_5_1 := UnderlyingRing( cat_1 ); + deduped_4_1 := objects_1[k_1]; + deduped_3_1 := Dimension( deduped_4_1 ); deduped_2_1 := List( objects_1, function ( c_2 ) return Dimension( c_2 ); end ); - morphism_attr_1_1 := UnionOfRows( HomalgZeroMatrix( Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_3_1, deduped_4_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_4_1 ), HomalgZeroMatrix( Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_3_1, deduped_4_1 ) ); - return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( morphism_attr_1_1 ) ), objects_1[k_1], UnderlyingMatrix, morphism_attr_1_1 ); + deduped_1_1 := UnionOfRows( HomalgZeroMatrix( Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_3_1, deduped_5_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_5_1 ), HomalgZeroMatrix( Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_3_1, deduped_5_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( deduped_1_1 ) ), deduped_4_1, UnderlyingMatrix, deduped_1_1 ); end ######## @@ -4482,14 +4487,15 @@ end ######## function ( cat_1, objects_1, k_1, P_1 ) - local morphism_attr_1_1, deduped_2_1, deduped_3_1, deduped_4_1; - deduped_4_1 := UnderlyingRing( cat_1 ); - deduped_3_1 := List( objects_1, Dimension )[k_1]; + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1, deduped_5_1; + deduped_5_1 := UnderlyingRing( cat_1 ); + deduped_4_1 := objects_1[k_1]; + deduped_3_1 := Dimension( deduped_4_1 ); deduped_2_1 := List( objects_1, function ( c_2 ) return Dimension( c_2 ); end ); - morphism_attr_1_1 := UnionOfRows( HomalgZeroMatrix( Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_3_1, deduped_4_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_4_1 ), HomalgZeroMatrix( Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_3_1, deduped_4_1 ) ); - return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( morphism_attr_1_1 ) ), objects_1[k_1], UnderlyingMatrix, morphism_attr_1_1 ); + deduped_1_1 := UnionOfRows( HomalgZeroMatrix( Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_3_1, deduped_5_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_5_1 ), HomalgZeroMatrix( Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_3_1, deduped_5_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( deduped_1_1 ) ), deduped_4_1, UnderlyingMatrix, deduped_1_1 ); end ######## @@ -4500,14 +4506,15 @@ end ######## function ( cat_1, objects_1, k_1 ) - local morphism_attr_1_1, deduped_2_1, deduped_3_1, deduped_4_1; - deduped_4_1 := UnderlyingRing( cat_1 ); - deduped_3_1 := List( objects_1, Dimension )[k_1]; + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1, deduped_5_1; + deduped_5_1 := UnderlyingRing( cat_1 ); + deduped_4_1 := objects_1[k_1]; + deduped_3_1 := Dimension( deduped_4_1 ); deduped_2_1 := List( objects_1, function ( c_2 ) return Dimension( c_2 ); end ); - morphism_attr_1_1 := UnionOfRows( HomalgZeroMatrix( Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_3_1, deduped_4_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_4_1 ), HomalgZeroMatrix( Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_3_1, deduped_4_1 ) ); - return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( morphism_attr_1_1 ) ), objects_1[k_1], UnderlyingMatrix, morphism_attr_1_1 ); + deduped_1_1 := UnionOfRows( HomalgZeroMatrix( Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_3_1, deduped_5_1 ), HomalgIdentityMatrix( deduped_3_1, deduped_5_1 ), HomalgZeroMatrix( Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_3_1, deduped_5_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( deduped_1_1 ) ), deduped_4_1, UnderlyingMatrix, deduped_1_1 ); end ######## @@ -4518,13 +4525,14 @@ end ######## function ( cat_1, objects_1, k_1, P_1 ) - local deduped_1_1, deduped_2_1, deduped_3_1; - deduped_3_1 := UnderlyingRing( cat_1 ); - deduped_2_1 := List( objects_1, Dimension )[k_1]; + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1; + deduped_4_1 := UnderlyingRing( cat_1 ); + deduped_3_1 := objects_1[k_1]; + deduped_2_1 := Dimension( deduped_3_1 ); deduped_1_1 := List( objects_1, function ( c_2 ) return Dimension( c_2 ); end ); - return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, objects_1[k_1], UnderlyingMatrix, UnionOfRows( HomalgZeroMatrix( Sum( deduped_1_1{[ 1 .. k_1 - 1 ]} ), deduped_2_1, deduped_3_1 ), HomalgIdentityMatrix( deduped_2_1, deduped_3_1 ), HomalgZeroMatrix( Sum( deduped_1_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_2_1, deduped_3_1 ) ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, deduped_3_1, UnderlyingMatrix, UnionOfRows( HomalgZeroMatrix( Sum( deduped_1_1{[ 1 .. k_1 - 1 ]} ), deduped_2_1, deduped_4_1 ), HomalgIdentityMatrix( deduped_2_1, deduped_4_1 ), HomalgZeroMatrix( Sum( deduped_1_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_2_1, deduped_4_1 ) ) ); end ######## @@ -4535,7 +4543,7 @@ end ######## function ( cat_1, morphisms_1, k_1 ) - local morphism_attr_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1; + local hoisted_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, deduped_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1; deduped_11_1 := Length( morphisms_1 ); deduped_10_1 := UnderlyingRing( cat_1 ); deduped_9_1 := List( morphisms_1, function ( logic_new_func_x_2 ) @@ -4543,17 +4551,17 @@ function ( cat_1, morphisms_1, k_1 ) end ); deduped_8_1 := Sum( deduped_9_1 ); deduped_7_1 := Sum( deduped_9_1{[ 1 .. k_1 - 1 ]} ) + 1; - hoisted_5_1 := List( morphisms_1, UnderlyingMatrix ); - hoisted_4_1 := deduped_11_1; - hoisted_3_1 := deduped_10_1; - hoisted_2_1 := deduped_9_1; + hoisted_4_1 := List( morphisms_1, UnderlyingMatrix ); + hoisted_3_1 := deduped_11_1; + hoisted_2_1 := deduped_10_1; + hoisted_1_1 := deduped_9_1; deduped_6_1 := List( [ 1 .. deduped_11_1 ], function ( logic_new_func_x_2 ) local deduped_1_2; - deduped_1_2 := hoisted_2_1[logic_new_func_x_2]; - return UnionOfRows( HomalgZeroMatrix( Sum( hoisted_2_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), deduped_1_2, hoisted_3_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_3_1 ), HomalgZeroMatrix( Sum( hoisted_2_1{[ (logic_new_func_x_2 + 1) .. hoisted_4_1 ]} ), deduped_1_2, hoisted_3_1 ) ) * hoisted_5_1[logic_new_func_x_2]; + deduped_1_2 := hoisted_1_1[logic_new_func_x_2]; + return UnionOfRows( HomalgZeroMatrix( Sum( hoisted_1_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), deduped_1_2, hoisted_2_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_2_1 ), HomalgZeroMatrix( Sum( hoisted_1_1{[ (logic_new_func_x_2 + 1) .. hoisted_3_1 ]} ), deduped_1_2, hoisted_2_1 ) ) * hoisted_4_1[logic_new_func_x_2]; end ); - morphism_attr_1_1 := CertainColumns( SyzygiesOfRows( UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} ) ), [ deduped_7_1 .. deduped_7_1 - 1 + deduped_9_1[k_1] ] ); - return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( morphism_attr_1_1 ) ), List( morphisms_1, Source )[k_1], UnderlyingMatrix, morphism_attr_1_1 ); + deduped_5_1 := CertainColumns( SyzygiesOfRows( UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} ) ), [ deduped_7_1 .. deduped_7_1 - 1 + deduped_9_1[k_1] ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( deduped_5_1 ) ), Source( morphisms_1[k_1] ), UnderlyingMatrix, deduped_5_1 ); end ######## @@ -4564,7 +4572,7 @@ end ######## function ( cat_1, morphisms_1, k_1, P_1 ) - local morphism_attr_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1; + local hoisted_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, deduped_5_1, deduped_6_1, deduped_7_1, deduped_8_1, deduped_9_1, deduped_10_1, deduped_11_1; deduped_11_1 := Length( morphisms_1 ); deduped_10_1 := UnderlyingRing( cat_1 ); deduped_9_1 := List( morphisms_1, function ( logic_new_func_x_2 ) @@ -4572,17 +4580,17 @@ function ( cat_1, morphisms_1, k_1, P_1 ) end ); deduped_8_1 := Sum( deduped_9_1 ); deduped_7_1 := Sum( deduped_9_1{[ 1 .. k_1 - 1 ]} ) + 1; - hoisted_5_1 := List( morphisms_1, UnderlyingMatrix ); - hoisted_4_1 := deduped_11_1; - hoisted_3_1 := deduped_10_1; - hoisted_2_1 := deduped_9_1; + hoisted_4_1 := List( morphisms_1, UnderlyingMatrix ); + hoisted_3_1 := deduped_11_1; + hoisted_2_1 := deduped_10_1; + hoisted_1_1 := deduped_9_1; deduped_6_1 := List( [ 1 .. deduped_11_1 ], function ( logic_new_func_x_2 ) local deduped_1_2; - deduped_1_2 := hoisted_2_1[logic_new_func_x_2]; - return UnionOfRows( HomalgZeroMatrix( Sum( hoisted_2_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), deduped_1_2, hoisted_3_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_3_1 ), HomalgZeroMatrix( Sum( hoisted_2_1{[ (logic_new_func_x_2 + 1) .. hoisted_4_1 ]} ), deduped_1_2, hoisted_3_1 ) ) * hoisted_5_1[logic_new_func_x_2]; + deduped_1_2 := hoisted_1_1[logic_new_func_x_2]; + return UnionOfRows( HomalgZeroMatrix( Sum( hoisted_1_1{[ 1 .. (logic_new_func_x_2 - 1) ]} ), deduped_1_2, hoisted_2_1 ), HomalgIdentityMatrix( deduped_1_2, hoisted_2_1 ), HomalgZeroMatrix( Sum( hoisted_1_1{[ (logic_new_func_x_2 + 1) .. hoisted_3_1 ]} ), deduped_1_2, hoisted_2_1 ) ) * hoisted_4_1[logic_new_func_x_2]; end ); - morphism_attr_1_1 := CertainColumns( SyzygiesOfRows( UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} ) ), [ deduped_7_1 .. deduped_7_1 - 1 + deduped_9_1[k_1] ] ); - return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( morphism_attr_1_1 ) ), List( morphisms_1, Source )[k_1], UnderlyingMatrix, morphism_attr_1_1 ); + deduped_5_1 := CertainColumns( SyzygiesOfRows( UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 1 .. deduped_11_1 - 1 ]} ) + -1 * UnionOfColumns( deduped_10_1, deduped_8_1, deduped_6_1{[ 2 .. deduped_11_1 ]} ) ), [ deduped_7_1 .. deduped_7_1 - 1 + deduped_9_1[k_1] ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( deduped_5_1 ) ), Source( morphisms_1[k_1] ), UnderlyingMatrix, deduped_5_1 ); end ######## @@ -5597,9 +5605,10 @@ end ######## function ( cat_1, alpha_1, tau_1 ) - local morphism_attr_1_1; - morphism_attr_1_1 := RightDivide( SyzygiesOfRows( SyzygiesOfColumns( UnderlyingMatrix( alpha_1 ) ) ), List( tau_1, UnderlyingMatrix )[2] ); - return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( morphism_attr_1_1 ) ), List( tau_1, Source )[2], UnderlyingMatrix, morphism_attr_1_1 ); + local deduped_1_1, deduped_2_1; + deduped_2_1 := tau_1[2]; + deduped_1_1 := RightDivide( SyzygiesOfRows( SyzygiesOfColumns( UnderlyingMatrix( alpha_1 ) ) ), UnderlyingMatrix( deduped_2_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( deduped_1_1 ) ), Source( deduped_2_1 ), UnderlyingMatrix, deduped_1_1 ); end ######## @@ -5610,9 +5619,10 @@ end ######## function ( cat_1, alpha_1, tau_1, I_1 ) - local morphism_attr_1_1; - morphism_attr_1_1 := RightDivide( SyzygiesOfRows( SyzygiesOfColumns( UnderlyingMatrix( alpha_1 ) ) ), List( tau_1, UnderlyingMatrix )[2] ); - return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( morphism_attr_1_1 ) ), List( tau_1, Source )[2], UnderlyingMatrix, morphism_attr_1_1 ); + local deduped_1_1, deduped_2_1; + deduped_2_1 := tau_1[2]; + deduped_1_1 := RightDivide( SyzygiesOfRows( SyzygiesOfColumns( UnderlyingMatrix( alpha_1 ) ) ), UnderlyingMatrix( deduped_2_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberRows( deduped_1_1 ) ), Source( deduped_2_1 ), UnderlyingMatrix, deduped_1_1 ); end ######## @@ -5731,9 +5741,10 @@ end ######## function ( cat_1, alpha_1, tau_1 ) - local morphism_attr_1_1; - morphism_attr_1_1 := LeftDivide( List( tau_1, UnderlyingMatrix )[1], SyzygiesOfColumns( SyzygiesOfRows( UnderlyingMatrix( alpha_1 ) ) ) ); - return CreateCapCategoryMorphismWithAttributes( cat_1, List( tau_1, Range )[1], CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( morphism_attr_1_1 ) ), UnderlyingMatrix, morphism_attr_1_1 ); + local deduped_1_1, deduped_2_1; + deduped_2_1 := tau_1[1]; + deduped_1_1 := LeftDivide( UnderlyingMatrix( deduped_2_1 ), SyzygiesOfColumns( SyzygiesOfRows( UnderlyingMatrix( alpha_1 ) ) ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Range( deduped_2_1 ), CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( deduped_1_1 ) ), UnderlyingMatrix, deduped_1_1 ); end ######## @@ -5744,9 +5755,10 @@ end ######## function ( cat_1, alpha_1, tau_1, C_1 ) - local morphism_attr_1_1; - morphism_attr_1_1 := LeftDivide( List( tau_1, UnderlyingMatrix )[1], SyzygiesOfColumns( SyzygiesOfRows( UnderlyingMatrix( alpha_1 ) ) ) ); - return CreateCapCategoryMorphismWithAttributes( cat_1, List( tau_1, Range )[1], CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( morphism_attr_1_1 ) ), UnderlyingMatrix, morphism_attr_1_1 ); + local deduped_1_1, deduped_2_1; + deduped_2_1 := tau_1[1]; + deduped_1_1 := LeftDivide( UnderlyingMatrix( deduped_2_1 ), SyzygiesOfColumns( SyzygiesOfRows( UnderlyingMatrix( alpha_1 ) ) ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Range( deduped_2_1 ), CreateCapCategoryObjectWithAttributes( cat_1, Dimension, NumberColumns( deduped_1_1 ) ), UnderlyingMatrix, deduped_1_1 ); end ######## diff --git a/LinearAlgebraForCAP/gap/precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi b/LinearAlgebraForCAP/gap/precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi index b45ab48371..460b5fc16a 100644 --- a/LinearAlgebraForCAP/gap/precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi +++ b/LinearAlgebraForCAP/gap/precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi @@ -200,15 +200,14 @@ end ######## function ( cat_1, alpha_1, S_1, i_1 ) - local deduped_1_1, deduped_2_1, deduped_3_1; - deduped_3_1 := Opposite( alpha_1 ); + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1; + deduped_4_1 := Opposite( alpha_1 ); + deduped_3_1 := S_1[i_1]; deduped_2_1 := List( S_1, function ( logic_new_func_x_2 ) return Dimension( Opposite( logic_new_func_x_2 ) ); end ); deduped_1_1 := Sum( deduped_2_1{[ 1 .. i_1 - 1 ]} ) + 1; - return CreateCapCategoryMorphismWithAttributes( cat_1, S_1[i_1], Range( alpha_1 ), Opposite, CreateCapCategoryMorphismWithAttributes( OppositeCategory( cat_1 ), Source( deduped_3_1 ), List( S_1, function ( x_2 ) - return Opposite( x_2 ); - end )[i_1], UnderlyingMatrix, CertainColumns( UnderlyingMatrix( deduped_3_1 ), [ deduped_1_1 .. deduped_1_1 - 1 + deduped_2_1[i_1] ] ) ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, deduped_3_1, Range( alpha_1 ), Opposite, CreateCapCategoryMorphismWithAttributes( OppositeCategory( cat_1 ), Source( deduped_4_1 ), Opposite( deduped_3_1 ), UnderlyingMatrix, CertainColumns( UnderlyingMatrix( deduped_4_1 ), [ deduped_1_1 .. deduped_1_1 - 1 + deduped_2_1[i_1] ] ) ) ); end ######## @@ -219,15 +218,14 @@ end ######## function ( cat_1, alpha_1, S_1, i_1 ) - local deduped_1_1, deduped_2_1, deduped_3_1; - deduped_3_1 := Opposite( alpha_1 ); + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1; + deduped_4_1 := Opposite( alpha_1 ); + deduped_3_1 := S_1[i_1]; deduped_2_1 := List( S_1, function ( logic_new_func_x_2 ) return Dimension( Opposite( logic_new_func_x_2 ) ); end ); deduped_1_1 := Sum( deduped_2_1{[ 1 .. i_1 - 1 ]} ) + 1; - return CreateCapCategoryMorphismWithAttributes( cat_1, Source( alpha_1 ), S_1[i_1], Opposite, CreateCapCategoryMorphismWithAttributes( OppositeCategory( cat_1 ), List( S_1, function ( x_2 ) - return Opposite( x_2 ); - end )[i_1], Range( deduped_3_1 ), UnderlyingMatrix, CertainRows( UnderlyingMatrix( deduped_3_1 ), [ deduped_1_1 .. deduped_1_1 - 1 + deduped_2_1[i_1] ] ) ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Source( alpha_1 ), deduped_3_1, Opposite, CreateCapCategoryMorphismWithAttributes( OppositeCategory( cat_1 ), Opposite( deduped_3_1 ), Range( deduped_4_1 ), UnderlyingMatrix, CertainRows( UnderlyingMatrix( deduped_4_1 ), [ deduped_1_1 .. deduped_1_1 - 1 + deduped_2_1[i_1] ] ) ) ); end ######## @@ -362,16 +360,15 @@ end ######## function ( cat_1, objects_1, k_1, P_1 ) - local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1; - deduped_4_1 := OppositeCategory( cat_1 ); - deduped_3_1 := UnderlyingRing( deduped_4_1 ); + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1, deduped_5_1; + deduped_5_1 := OppositeCategory( cat_1 ); + deduped_4_1 := objects_1[k_1]; + deduped_3_1 := UnderlyingRing( deduped_5_1 ); deduped_2_1 := List( objects_1, function ( logic_new_func_x_2 ) return Dimension( Opposite( logic_new_func_x_2 ) ); end ); deduped_1_1 := deduped_2_1[k_1]; - return CreateCapCategoryMorphismWithAttributes( cat_1, objects_1[k_1], P_1, Opposite, CreateCapCategoryMorphismWithAttributes( deduped_4_1, Opposite( P_1 ), List( objects_1, function ( x_2 ) - return Opposite( x_2 ); - end )[k_1], UnderlyingMatrix, UnionOfRows( HomalgZeroMatrix( Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_1_1, deduped_3_1 ), HomalgIdentityMatrix( deduped_1_1, deduped_3_1 ), HomalgZeroMatrix( Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_1_1, deduped_3_1 ) ) ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, deduped_4_1, P_1, Opposite, CreateCapCategoryMorphismWithAttributes( deduped_5_1, Opposite( P_1 ), Opposite( deduped_4_1 ), UnderlyingMatrix, UnionOfRows( HomalgZeroMatrix( Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_1_1, deduped_3_1 ), HomalgIdentityMatrix( deduped_1_1, deduped_3_1 ), HomalgZeroMatrix( Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_1_1, deduped_3_1 ) ) ) ); end ######## @@ -749,16 +746,15 @@ end ######## function ( cat_1, objects_1, k_1, P_1 ) - local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1; - deduped_4_1 := OppositeCategory( cat_1 ); - deduped_3_1 := UnderlyingRing( deduped_4_1 ); + local deduped_1_1, deduped_2_1, deduped_3_1, deduped_4_1, deduped_5_1; + deduped_5_1 := OppositeCategory( cat_1 ); + deduped_4_1 := objects_1[k_1]; + deduped_3_1 := UnderlyingRing( deduped_5_1 ); deduped_2_1 := List( objects_1, function ( logic_new_func_x_2 ) return Dimension( Opposite( logic_new_func_x_2 ) ); end ); deduped_1_1 := deduped_2_1[k_1]; - return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, objects_1[k_1], Opposite, CreateCapCategoryMorphismWithAttributes( deduped_4_1, List( objects_1, function ( x_2 ) - return Opposite( x_2 ); - end )[k_1], Opposite( P_1 ), UnderlyingMatrix, UnionOfColumns( HomalgZeroMatrix( deduped_1_1, Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_3_1 ), HomalgIdentityMatrix( deduped_1_1, deduped_3_1 ), HomalgZeroMatrix( deduped_1_1, Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_3_1 ) ) ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, deduped_4_1, Opposite, CreateCapCategoryMorphismWithAttributes( deduped_5_1, Opposite( deduped_4_1 ), Opposite( P_1 ), UnderlyingMatrix, UnionOfColumns( HomalgZeroMatrix( deduped_1_1, Sum( deduped_2_1{[ 1 .. k_1 - 1 ]} ), deduped_3_1 ), HomalgIdentityMatrix( deduped_1_1, deduped_3_1 ), HomalgZeroMatrix( deduped_1_1, Sum( deduped_2_1{[ k_1 + 1 .. Length( objects_1 ) ]} ), deduped_3_1 ) ) ) ); end ########