  
  [1X5 Examples[0X
  
  
  [1X5.1 An Easy Polynomial Example[0X
  
  The  ground  ring  used in this example is F_3[x,y]. We want to see, how the
  different  rings in this package can be used to localize at different points
  and how the results differ.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> LoadPackage("RingsForHomalg");;[0X
    [4Xgap> F3xy := HomalgRingOfIntegersInSingular(3) * "x,y";;[0X
    [4Xgap> x1 := HomalgRingElement( "x+2", F3xy );;[0X
    [4Xgap> y0 := HomalgRingElement( "y", F3xy );;[0X
    [4Xgap> LoadPackage("LocalizeRingForHomalg");;[0X
    [4Xgap> R00 := LocalizeAtZero( F3xy );;[0X
    [4Xgap> R10 := LocalizeAt( F3xy, [ x1, y0 ] );;[0X
    [4Xgap> RMora := LocalizePolynomialRingAtZeroWithMora( F3xy );;[0X
    [4Xgap> M := HomalgMatrix( "[\[0X
    [4X>        y^3+2*y^2+x+x^2+2*x*y+y^4+x*y^2, \[0X
    [4X>        x*y^3+2*x^2*y+y^3+y^2+x+2*y+x^2, \[0X
    [4X>        x^2*y^2+2*x^3+x^2*y+y^3+2*x^2+2*x*y+y^2+2*y\[0X
    [4X>      ]", 1, 3, F3xy );;[0X
    [4Xgap> LoadPackage( "Modules" );;[0X
    [4Xgap> I := RightPresentation( M );;[0X
    [4Xgap> M00 := HomalgLocalMatrix( M, R00 );;[0X
    [4Xgap> M10 := HomalgLocalMatrix( M, R10 );;[0X
    [4Xgap> MMora := HomalgLocalMatrix( M, RMora );;[0X
    [4Xgap> I00 := RightPresentation( M00 );;[0X
    [4Xgap> I10 := RightPresentation( M10 );;[0X
    [4Xgap> IMora := RightPresentation( MMora );;[0X
  [4X------------------------------------------------------------------[0X
  
  This ring is able to compute a standard basis of the module.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Display( IMora );[0X
    [4XGF(3)[x,y]_< x, y >/< (x+x^2-x*y-y^2+x*y^2+y^3+y^4)/1, (x-y+x^2+y^2-x^2*y+y^3+\[0X
    [4Xx*y^3)/1, (-y-x^2-x*y+y^2-x^3+x^2*y+y^3+x^2*y^2)/1 >[0X
    [4Xgap> ByASmallerPresentation( IMora );[0X
    [4X<A cyclic right module on a cyclic generator satisfying 2 relations>[0X
    [4Xgap> Display( IMora );[0X
    [4XGF(3)[x,y]_< x, y >/< x/1, y/1 >[0X
  [4X------------------------------------------------------------------[0X
  
  This  ring  recognizes, that the module is not zero, but is not able to find
  better generators.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Display( I00 );[0X
    [4XGF(3)[x,y]_< x, y >/< (y^4+x*y^2+y^3+x^2-x*y-y^2+x)/1, (x*y^3-x^2*y+y^3+x^2+y^\[0X
    [4X2+x-y)/1, (x^2*y^2-x^3+x^2*y+y^3-x^2-x*y+y^2-y)/1 >[0X
    [4Xgap> ByASmallerPresentation( I00 );[0X
    [4X<A cyclic right module on a cyclic generator satisfying 3 relations>[0X
    [4Xgap> Display( I00 );[0X
    [4XGF(3)[x,y]_< x, y >/< (y^4+x*y^2+y^3+x^2-x*y-y^2+x)/1, (x*y^3-x^2*y+y^3+x^2+y^\[0X
    [4X2+x-y)/1, (x^2*y^2-x^3+x^2*y+y^3-x^2-x*y+y^2-y)/1 >[0X
  [4X------------------------------------------------------------------[0X
  
  We are able to change the ring, to compute a nicer basis.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> I00ToMora := RMora * I00;[0X
    [4X<A cyclic right module on a cyclic generator satisfying 3 relations>[0X
    [4Xgap> Display( I00ToMora );[0X
    [4XGF(3)[x,y]_< x, y >/< (x+x^2-x*y-y^2+x*y^2+y^3+y^4)/1, (x-y+x^2+y^2-x^2*y+y^3+\[0X
    [4Xx*y^3)/1, (-y-x^2-x*y+y^2-x^3+x^2*y+y^3+x^2*y^2)/1 >[0X
    [4Xgap> ByASmallerPresentation( I00ToMora );[0X
    [4X<A cyclic right module on a cyclic generator satisfying 2 relations>[0X
    [4Xgap> Display( I00ToMora );[0X
    [4XGF(3)[x,y]_< x, y >/< x/1, y/1 >[0X
  [4X------------------------------------------------------------------[0X
  
  We are able to find out, that this module is actually zero.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Display( I10 );[0X
    [4XGF(3)[x,y]_< x-1, y >/< (y^4+x*y^2+y^3+x^2-x*y-y^2+x)/1, (x*y^3-x^2*y+y^3+x^2+\[0X
    [4Xy^2+x-y)/1, (x^2*y^2-x^3+x^2*y+y^3-x^2-x*y+y^2-y)/1 >[0X
    [4Xgap> ByASmallerPresentation( I10 );[0X
    [4X<A zero right module>[0X
    [4Xgap> Display( I10 );[0X
    [4X0[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1X5.2 Hom(Hom(-,Z128),Z16)[0X
  
  The following example is taken from Section 2 of [BR06].
  The  computation  takes place over the local ring R=ℤ_< 2> (i.e. ℤ localized
  at the maximal ideal generated by 2).
  
  Here we compute the (infinite) long exact homology sequence of the covariant
  functor Hom(Hom(-,R/2^7R),R/2^4R) (and its left derived functors) applied to
  the short exact sequence
  0 -> M_=R/2^2R --alpha_1--> M=R/2^5R --alpha_2--> _M=R/2^3R -> 0.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> LoadPackage( "LocalizeRingForHomalg" );;[0X
    [4Xgap> GlobalR := HomalgRingOfIntegersInExternalGAP(  );[0X
    [4X<A homalg external ring residing in the CAS GAP>[0X
    [4Xgap> LoadPackage( "RingsForHomalg" );;[0X
    [4Xgap> R := LocalizeAt( GlobalR , [ 2 ] );[0X
    [4X<A homalg local ring>[0X
    [4Xgap> M := LeftPresentation( HomalgMatrix( [ 2^5 ], R ) );[0X
    [4X<A cyclic left module presented by an unknown number of relations for a cyclic\[0X
    [4X generator>[0X
    [4Xgap> _M := LeftPresentation( HomalgMatrix( [ 2^3 ], R ) );[0X
    [4X<A cyclic left module presented by an unknown number of relations for a cyclic\[0X
    [4X generator>[0X
    [4Xgap> alpha2 := HomalgMap( HomalgMatrix( [ 1 ], R ), M, _M );[0X
    [4X<A "homomorphism" of left modules>[0X
    [4Xgap> M_ := Kernel( alpha2 );[0X
    [4X<A cyclic left module presented by yet unknown relations for a cyclic generato\[0X
    [4Xr>[0X
    [4Xgap> alpha1 := KernelEmb( alpha2 );[0X
    [4X<A monomorphism of left modules>[0X
    [4Xgap> seq := HomalgComplex( alpha2 );[0X
    [4X<A "complex" containing a single morphism of left modules at degrees[0X
    [4X[ 0 .. 1 ]>[0X
    [4Xgap> Add( seq, alpha1 );[0X
    [4Xgap> IsShortExactSequence( seq );[0X
    [4Xtrue[0X
    [4Xgap> K := LeftPresentation( HomalgMatrix( [ 2^7 ], R ) );[0X
    [4X<A cyclic left module presented by an unknown number of relations for a cyclic\[0X
    [4X generator>[0X
    [4Xgap> L := RightPresentation( HomalgMatrix( [ 2^4 ], R ) );[0X
    [4X<A cyclic right module on a cyclic generator satisfying an unknown number of r\[0X
    [4Xelations>[0X
    [4Xgap> triangle := LHomHom( 4, seq, K, L, "t" );[0X
    [4X<An exact triangle containing 3 morphisms of left complexes at degrees[0X
    [4X[ 1, 2, 3, 1 ]>[0X
    [4Xgap> lehs := LongSequence( triangle );[0X
    [4X<A sequence containing 14 morphisms of left modules at degrees [ 0 .. 14 ]>[0X
    [4Xgap> ByASmallerPresentation( lehs );[0X
    [4X<A non-zero sequence containing 14 morphisms of left modules at degrees[0X
    [4X[ 0 .. 14 ]>[0X
    [4Xgap> IsExactSequence( lehs );[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1X5.3 ResidueClass[0X
  
  We  want  to  show,  how  localization  can work together with residue class
  rings.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> LoadPackage( "RingsForHomalg" );;[0X
    [4Xgap> Qxy := HomalgFieldOfRationalsInDefaultCAS( ) * "x,y";;[0X
    [4Xgap> wmat := HomalgMatrix([0X
    [4X>           "[ y^3-y^2 , x^3-x^2 , y^3+y^2 , x^3+x^2 ]",[0X
    [4X>           2, 2, Qxy );[0X
    [4X<A homalg external 2 by 2 matrix>[0X
    [4Xgap> ec := HomalgRingElement( "-x^3-x^2+2*y^2", Qxy );[0X
    [4X-x^3-x^2+2*y^2[0X
  [4X------------------------------------------------------------------[0X
  
  Compute globally:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> LoadPackage( "Modules" );;[0X
    [4Xgap> W := LeftPresentation( wmat );[0X
    [4X<A left module presented by 2 relations for 2 generators>[0X
    [4Xgap> Res := Resolution( 2 , W );[0X
    [4X<A right acyclic complex containing 2 morphisms of left modules at degrees[0X
    [4X[ 0 .. 2 ]>[0X
    [4X gap> Display ( Res );[0X
    [4X -------------------------[0X
    [4X at homology degree: 2[0X
    [4X 0[0X
    [4X -------------------------[0X
    [4X (an empty 0 x 2 matrix)[0X
    [4X [0X
    [4X the map is currently represented by the above 0 x 2 matrix[0X
    [4X ------------v------------[0X
    [4X at homology degree: 1[0X
    [4X Q[x,y]^(1 x 2)[0X
    [4X -------------------------[0X
    [4X y^2,      x^2,[0X
    [4X x*y^2-y^3,0[0X
    [4X [0X
    [4X the map is currently represented by the above 2 x 2 matrix[0X
    [4X ------------v------------[0X
    [4X at homology degree: 0[0X
    [4X Q[x,y]^(1 x 2)[0X
    [4X -------------------------[0X
  [4X------------------------------------------------------------------[0X
  
  Try a localization of a residue class ring:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> R1 := Qxy / ec;[0X
    [4X<A homalg residue class ring>[0X
    [4Xgap> wmat1 := R1 * wmat;[0X
    [4X<A homalg residue class 2 by 2 matrix>[0X
    [4Xgap> LoadPackage( "LocalizeRingForHomalg" );;[0X
    [4Xgap> R10 := LocalizeAt( R1 ,[0X
    [4X>          [ HomalgRingElement( "x", R1 ),[0X
    [4X>            HomalgRingElement( "y", R1 ) ][0X
    [4X>        );[0X
    [4X<A homalg local ring>[0X
    [4Xgap> wmat10 := HomalgLocalMatrix( wmat, R10 );[0X
    [4X<A homalg local 2 by 2 matrix>[0X
    [4Xgap> W10 := LeftPresentation( wmat10 );[0X
    [4X<A left module presented by 2 relations for 2 generators>[0X
    [4Xgap> Res10 := Resolution( 2 , W10 );[0X
    [4X<A right acyclic complex containing 2 morphisms of left modules at degrees[0X
    [4X[ 0 .. 2 ]>[0X
    [4X gap> Display( Res10 );[0X
    [4X -------------------------[0X
    [4X at homology degree: 2[0X
    [4X 0[0X
    [4X -------------------------[0X
    [4X (an empty 0 x 2 matrix)[0X
    [4X [0X
    [4X the map is currently represented by the above 0 x 2 matrix[0X
    [4X ------------v------------[0X
    [4X at homology degree: 1[0X
    [4X Q[x,y]/( -x^3-x^2+2*y^2 )_< |[ x ]|, |[ y ]| >^(1 x 2)[0X
    [4X -------------------------[0X
    [4X y^2,    x^2,[0X
    [4X y^3+y^2,2*y^2[0X
    [4X [0X
    [4X modulo [ -x^3-x^2+2*y^2 ][0X
    [4X / |[ 1 ]|[0X
    [4X [0X
    [4X the map is currently represented by the above 2 x 2 matrix[0X
    [4X ------------v------------[0X
    [4X at homology degree: 0[0X
    [4X Q[x,y]/( -x^3-x^2+2*y^2 )_< |[ x ]|, |[ y ]| >^(1 x 2)[0X
    [4X -------------------------[0X
  [4X------------------------------------------------------------------[0X
  
  Try a residue class ring of a localization:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> R0 := LocalizeAtZero( Qxy );[0X
    [4X<A homalg local ring>[0X
    [4Xgap> wmat0 := R0 * wmat;[0X
    [4X<A homalg local 2 by 2 matrix>[0X
    [4Xgap> R01 := R0 / ( ec / R0 );[0X
    [4X<A homalg residue class ring>[0X
    [4Xgap> wmat01 := R01 * wmat0;[0X
    [4X<A homalg residue class 2 by 2 matrix>[0X
    [4Xgap> W01 := LeftPresentation( wmat01 );[0X
    [4X<A left module presented by 2 relations for 2 generators>[0X
    [4Xgap> Res01 := Resolution( 2 , W01 );[0X
    [4X<A right acyclic complex containing 2 morphisms of left modules at degrees[0X
    [4X[ 0 .. 2 ]>[0X
    [4X gap> Display(Res01);[0X
    [4X -------------------------[0X
    [4X at homology degree: 2[0X
    [4X 0[0X
    [4X -------------------------[0X
    [4X (an empty 0 x 2 matrix)[0X
    [4X [0X
    [4X the map is currently represented by the above 0 x 2 matrix[0X
    [4X ------------v------------[0X
    [4X at homology degree: 1[0X
    [4X Q[x,y]_< x, y >/( (-x^3-x^2+2*y^2)/1 )^(1 x 2)[0X
    [4X -------------------------[0X
    [4X y^2,    x^2,[0X
    [4X y^3+y^2,2*y^2[0X
    [4X / 1[0X
    [4X [0X
    [4X modulo [ (-x^3-x^2+2*y^2)/1 ][0X
    [4X [0X
    [4X the map is currently represented by the above 2 x 2 matrix[0X
    [4X ------------v------------[0X
    [4X at homology degree: 0[0X
    [4X Q[x,y]_< x, y >/( (-x^3-x^2+2*y^2)/1 )^(1 x 2)[0X
    [4X -------------------------[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1X5.4 Testing the Intersection Formula[0X
  
  We  want  to  check  Serre's intersection formula i(I_1, I_2; 0)=sum_i(-1)^i
  length(Tor^R_0_i(R_0/I_1,R_0/I_2)) on an easy affine example.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X [0X
    [4Xgap> LoadPackage( "RingsForHomalg" );;[0X
    [4Xgap> R := HomalgFieldOfRationalsInSingular() * "w,x,y,z";;[0X
    [4Xgap> LoadPackage( "LocalizeRingForHomalg" );;[0X
    [4Xgap> R0 := LocalizePolynomialRingAtZeroWithMora( R );;[0X
    [4Xgap> M1 := HomalgMatrix( "[\[0X
    [4X>        (w-x^2)*y, \[0X
    [4X>        (w-x^2)*z, \[0X
    [4X>        (x-w^2)*y, \[0X
    [4X>        (x-w^2)*z  \[0X
    [4X>      ]", 4, 1, R );;[0X
    [4Xgap> M2 := HomalgMatrix( "[\[0X
    [4X>        (w-x^2)-y, \[0X
    [4X>        (x-w^2)-z  \[0X
    [4X>      ]", 2, 1, R );;[0X
    [4Xgap> LoadPackage( "Modules" );;[0X
    [4Xgap> RmodI1 := LeftPresentation( M1 );;[0X
    [4Xgap> RmodI2 := LeftPresentation( M2 );;[0X
    [4Xgap> T:=Tor( RmodI1, RmodI2 );[0X
    [4X<A graded homology object consisting of 4 left modules at degrees [ 0 .. 3 ]>[0X
    [4Xgap> List( ObjectsOfComplex( T ), AffineDegree );[0X
    [4X[ 12, 4, 0, 0 ][0X
  [4X------------------------------------------------------------------[0X
  
  We read, that the intersection multiplicity is 12-4=8 globally.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> M10 := R0 * M1;[0X
    [4X<A homalg local 4 by 1 matrix>[0X
    [4Xgap> M20 := R0 * M2;[0X
    [4X<A homalg local 2 by 1 matrix>[0X
    [4Xgap> R0modI10 := LeftPresentation( M10 );;[0X
    [4Xgap> R0modI20 := LeftPresentation( M20 );;[0X
    [4Xgap> T0 := Tor( R0modI10, R0modI20 );[0X
    [4X<A graded homology object consisting of 4 left modules at degrees [ 0 .. 3 ]>[0X
    [4Xgap> List( ObjectsOfComplex( T0 ), AffineDegree );[0X
    [4X[ 3, 1, 0, 0 ][0X
  [4X------------------------------------------------------------------[0X
  
  The intersection multiplicity at zero is 3-1=2.
  
