This is Complexes.info, produced by Macaulay2, version 1.21

Complexes -- development package for beta testing new version of chain complexes
********************************************************************************

Description
===========

This package develops new data types and routines for homological algebra.
Eventually, it will replace the current facilities for homological algebra. We
are making this available in order to get feedback from users before making
this change.  Please email the authors with any and all comments or
suggestions.

The overarching goal is to make all of the homological algebra routines
functorial. For instance, we have canonical maps,
associated to kernels, cokernels, images, coimages, cones, and cylinders.

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * Basic invariants and properties, --
    information about accessing basic features
  * Working with Ext -- information about functorial
    properties
  * Working with Tor -- information about functorial
    properties
  * Towards computing in the derived category

Authors
=======

  * Gregory G. Smith (see http://www.mast.queensu.ca/~ggsmith )
    <ggsmith@mast.queensu.ca>
  * Mike Stillman (see http://www.math.cornell.edu/~mike )
    <mike@math.cornell.edu>

Version
=======

This documentation describes version 0.9999 of Complexes.

Source code
===========

The source code from which this documentation is derived is in the file
Complexes.m2 (see common/share/Macaulay2/Complexes.m2 ). The auxiliary files
accompanying it are in the directory Complexes/ (see
common/share/Macaulay2/Complexes/ ).

Exports
=======

  * Types
      * Complex -- the class of all chain complexes
      * ComplexMap -- the class of all maps between chain
        complexes
  * Functions and commands
      * augmentationMap -- map from a free resolution
        to a module regarded as a complex
      * canonicalMap -- gets the natural map arising from
        various constructions
      * "canonicalTruncation" -- see canonicalTruncation(Complex,ZZ,ZZ),
        -- reducing the number of
        non-zero terms of a complex
      * complex -- make a chain complex
      * concentration -- indices on which a complex may
        be non-zero
      * "connectingExtMap" -- see connectingExtMap(Module,Matrix,Matrix),
        -- makes the connecting
        maps in Ext
      * "connectingMap" -- see connectingMap(ComplexMap,ComplexMap),
        -- construct the connecting
        homomorphism on homology
      * "connectingTorMap" -- see connectingTorMap(Module,Matrix,Matrix),
        -- makes the connecting
        maps in Tor
      * cylinder -- make the mapping cylinder of a morphism of
        chain complexes
      * freeResolution -- compute a free resolution of a
        module or ideal
      * "horseshoeResolution" -- see horseshoeResolution(Complex),
        -- make the horseshoe resolution
      * "isComplexMorphism" -- see isComplexMorphism(ComplexMap),
        -- whether a complex map is a
        morphism of complexes
      * isExact -- whether a complex is exact
      * "isFree" -- see isFree(Complex), -- whether
        a complex consists of free modules
      * "isNullHomotopic" -- see isNullHomotopic(ComplexMap),
        -- whether a map of complexes is
        null-homotopic
      * "isNullHomotopyOf" -- see
        isNullHomotopyOf(ComplexMap,ComplexMap),
        -- whether the first map
        of chain complexes is a null homotopy for the second
      * "isQuasiIsomorphism" -- see isQuasiIsomorphism(ComplexMap),
        -- whether a map of complexes is a
        quasi-isomorphism
      * "isShortExactSequence" -- see isShortExactSequence(Complex),
        -- whether a chain complex is a
        short exact sequence
      * "koszulComplex" -- see koszulComplex(Matrix),
        -- makes the Koszul complex
      * "homotopyMap" -- see
        liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap),
        -- lift a
        map of chain complexes along a quasi-isomorphism
      * "liftMapAlongQuasiIsomorphism" -- see
        liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap),
        -- lift a
        map of chain complexes along a quasi-isomorphism
      * "longExactSequence" -- see
        longExactSequence(ComplexMap,ComplexMap),
        -- make the long exact
        sequence in homology
      * "minimize" -- see minimize(Complex), -- a
        quasi-isomorphic complex whose terms have minimal rank
      * "naiveTruncation" -- see naiveTruncation(Complex,ZZ,ZZ),
        -- drops all terms of a complex
        outside a given interval
      * "nullHomotopy" -- see nullHomotopy(ComplexMap),
        -- a map which is a candidate for being a
        null homotopy
      * "randomComplexMap" -- see randomComplexMap(Complex,Complex),
        -- a random map of chain
        complexes
      * resolutionMap -- map from a free resolution to
        the given complex
      * "tensorCommutativity" -- see tensorCommutativity(Module,Module),
        -- make the canonical
        isomorphism arising from commutativity
      * "torSymmetry" -- see torSymmetry(ZZ,Module,Module),
        -- makes the canonical
        isomorphism realizing the symmetry of Tor
      * "yonedaExtension'" -- see yonedaExtension'(Complex),
        -- identifies the element of Ext
        corresponding to an extension
      * "yonedaExtension" -- see yonedaExtension(Matrix),
        -- creates a chain complex representing an
        extension of modules
      * "yonedaMap'" -- see yonedaMap'(ComplexMap),
        -- identifies the element of Ext
        corresponding to a map of free resolutions
      * "yonedaMap" -- see yonedaMap(Matrix), --
        creates a chain complex map representing an extension of modules
      * "yonedaProduct" -- see yonedaProduct(Matrix,Matrix),
        -- make the product of two elements
        in Ext modules
  * Methods
      * "- ComplexMap" -- see arithmetic with complex maps,
        -- perform arithmetic operations on complex maps
      * "ComplexMap * Number" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "ComplexMap * RingElement" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "ComplexMap + ComplexMap" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "ComplexMap + Number" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "ComplexMap + RingElement" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "ComplexMap - ComplexMap" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "ComplexMap - Number" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "ComplexMap - RingElement" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "Number * ComplexMap" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "Number + ComplexMap" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "Number - ComplexMap" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "RingElement * ComplexMap" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "RingElement + ComplexMap" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "RingElement - ComplexMap" -- see arithmetic with complex maps,
        -- perform arithmetic operations on
        complex maps
      * "augmentationMap(Complex)" -- see augmentationMap,
        -- map from a free resolution to a module regarded as
        a complex
      * betti(Complex) -- display of degrees in a
        complex
      * "canonicalMap(Complex,Complex)" -- see canonicalMap,
        -- gets the natural map arising from various
        constructions
      * "canonicalTruncation(Complex,InfiniteNumber,InfiniteNumber)" -- see
        canonicalTruncation(Complex,ZZ,ZZ),
        -- reducing the number of
        non-zero terms of a complex
      * "canonicalTruncation(Complex,InfiniteNumber,ZZ)" -- see
        canonicalTruncation(Complex,ZZ,ZZ),
        -- reducing the number of
        non-zero terms of a complex
      * "canonicalTruncation(Complex,Nothing,ZZ)" -- see
        canonicalTruncation(Complex,ZZ,ZZ),
        -- reducing the number of
        non-zero terms of a complex
      * "canonicalTruncation(Complex,Sequence)" -- see
        canonicalTruncation(Complex,ZZ,ZZ),
        -- reducing the number of
        non-zero terms of a complex
      * "canonicalTruncation(Complex,ZZ,InfiniteNumber)" -- see
        canonicalTruncation(Complex,ZZ,ZZ),
        -- reducing the number of
        non-zero terms of a complex
      * "canonicalTruncation(Complex,ZZ,Nothing)" -- see
        canonicalTruncation(Complex,ZZ,ZZ),
        -- reducing the number of
        non-zero terms of a complex
      * canonicalTruncation(Complex,ZZ,ZZ)
        -- reducing the number of
        non-zero terms of a complex
      * "canonicalTruncation(ComplexMap,InfiniteNumber,InfiniteNumber)" -- see
        canonicalTruncation(ComplexMap,ZZ,ZZ),
        -- reducing the number
        of non-zero terms of a complex
      * "canonicalTruncation(ComplexMap,InfiniteNumber,ZZ)" -- see
        canonicalTruncation(ComplexMap,ZZ,ZZ),
        -- reducing the number
        of non-zero terms of a complex
      * "canonicalTruncation(ComplexMap,Nothing,ZZ)" -- see
        canonicalTruncation(ComplexMap,ZZ,ZZ),
        -- reducing the number
        of non-zero terms of a complex
      * "canonicalTruncation(ComplexMap,Sequence)" -- see
        canonicalTruncation(ComplexMap,ZZ,ZZ),
        -- reducing the number
        of non-zero terms of a complex
      * "canonicalTruncation(ComplexMap,ZZ,InfiniteNumber)" -- see
        canonicalTruncation(ComplexMap,ZZ,ZZ),
        -- reducing the number
        of non-zero terms of a complex
      * "canonicalTruncation(ComplexMap,ZZ,Nothing)" -- see
        canonicalTruncation(ComplexMap,ZZ,ZZ),
        -- reducing the number
        of non-zero terms of a complex
      * canonicalTruncation(ComplexMap,ZZ,ZZ)
        -- reducing the number
        of non-zero terms of a complex
      * chainComplex(Complex) -- translate
        between data types for chain complexes
      * chainComplex(ComplexMap), --
        translate between data types for chain complexes
      * coimage(ComplexMap) -- make the coimage
        of a map of complexes
      * cokernel(ComplexMap) -- make the
        cokernel of a map of complexes
      * "complex(List)" -- see complex, -- make a chain complex
      * Complex ** Complex -- tensor product of
        complexes
      * "Complex ** Module" -- see Complex ** Complex,
        -- tensor product of complexes
      * "Module ** Complex" -- see Complex ** Complex,
        -- tensor product of complexes
      * "tensor(Complex,Complex)" -- see Complex ** Complex,
        -- tensor product of complexes
      * Complex ** Matrix -- create the tensor
        product of a complex and a map of modules
      * "Matrix ** Complex" -- see Complex ** Matrix,
        -- create the tensor product of a complex and a map of modules
      * Complex == Complex -- whether two complexes
        are equal
      * "Complex == ZZ" -- see Complex == Complex, --
        whether two complexes are equal
      * "ZZ == Complex" -- see Complex == Complex, --
        whether two complexes are equal
      * "Complex ^ Array" -- see Complex _ Array, --
        the canonical inclusion or projection map of a direct sum
      * Complex _ Array -- the canonical inclusion or
        projection map of a direct sum
      * "Complex ^ ZZ" -- see Complex _ ZZ, -- access
        individual object in a complex
      * Complex _ ZZ -- access individual object in a
        complex
      * Complex Array -- shift a complex or complex map
      * "ComplexMap Array" -- see Complex Array, -- shift
        a complex or complex map
      * complex(ChainComplex) -- translate
        between data types for chain complexes
      * complex(ChainComplexMap), --
        translate between data types for chain complex maps
      * complex(Complex) -- make a complex by
        reindexing the terms of the complex
      * complex(ComplexMap) -- make a complex
        by specifying the differential
      * complex(HashTable) -- make a chain
        complex
      * "complex(Ideal)" -- see complex(Module), --
        make a chain complex of length zero
      * complex(Module) -- make a chain complex of
        length zero
      * "complex(Ring)" -- see complex(Module), --
        make a chain complex of length zero
      * ComplexMap * ComplexMap, --
        composition of homomorphisms of complexes
      * "Complex ** ComplexMap" -- see ComplexMap ** ComplexMap,
        -- the map of complexes between tensor
        complexes
      * "ComplexMap ** Complex" -- see ComplexMap ** ComplexMap,
        -- the map of complexes between tensor
        complexes
      * ComplexMap ** ComplexMap -- the
        map of complexes between tensor complexes
      * "ComplexMap ** Module" -- see ComplexMap ** ComplexMap,
        -- the map of complexes between tensor
        complexes
      * "Module ** ComplexMap" -- see ComplexMap ** ComplexMap,
        -- the map of complexes between tensor
        complexes
      * "tensor(ComplexMap,ComplexMap)" -- see ComplexMap ** ComplexMap,
        -- the map of complexes between tensor
        complexes
      * ComplexMap ++ ComplexMap -- direct sum
        of complex maps
      * "directSum(ComplexMap)" -- see ComplexMap ++ ComplexMap,
        -- direct sum of complex maps
      * ComplexMap == ComplexMap -- whether
        two complex maps are equal
      * "ComplexMap == ZZ" -- see ComplexMap == ComplexMap,
        -- whether two complex maps are equal
      * "ZZ == ComplexMap" -- see ComplexMap == ComplexMap,
        -- whether two complex maps are equal
      * ComplexMap ^ Array -- the composition with
        the canonical inclusion or projection map
      * "ComplexMap _ Array" -- see ComplexMap ^ Array,
        -- the composition with the canonical inclusion or projection
        map
      * ComplexMap ^ ZZ -- the n-fold composition
      * ComplexMap _ ZZ -- access individual matrices
        in a complex map
      * ComplexMap | ComplexMap -- join or
        concatenate maps horizontally
      * ComplexMap || ComplexMap -- join or
        concatenate maps vertically
      * components(Complex) -- list the
        components of a direct sum
      * components(ComplexMap) -- list the
        components of a direct sum
      * "concentration(Complex)" -- see concentration, --
        indices on which a complex may be non-zero
      * "max(Complex)" -- see concentration, -- indices on
        which a complex may be non-zero
      * "min(Complex)" -- see concentration, -- indices on
        which a complex may be non-zero
      * concentration(ComplexMap), --
        indices on which a complex map may be non-zero
      * cone(ComplexMap) -- make the mapping cone
        of a morphism of chain complexes
      * "connectingExtMap(Matrix,Matrix,Module)" -- see
        connectingExtMap(Module,Matrix,Matrix),
        -- makes the connecting
        maps in Ext
      * connectingExtMap(Module,Matrix,Matrix)
        -- makes the connecting
        maps in Ext
      * connectingMap(ComplexMap,ComplexMap)
        -- construct the connecting
        homomorphism on homology
      * "connectingTorMap(Matrix,Matrix,Module)" -- see
        connectingTorMap(Module,Matrix,Matrix),
        -- makes the connecting
        maps in Tor
      * connectingTorMap(Module,Matrix,Matrix)
        -- makes the connecting
        maps in Tor
      * "cylinder(ComplexMap)" -- see cylinder, -- make the
        mapping cylinder of a morphism of chain complexes
      * degree(ComplexMap) -- get the degree of
        a map of chain complexes
      * "Symbol ^ Complex" -- see differential of a chain complex,
        -- get the maps between the terms in a
        complex
      * "Complex ++ Complex" -- see directSum(Complex),
        -- direct sum of complexes
      * directSum(Complex) -- direct sum of
        complexes
      * dual(Complex) -- make the dual of a complex
      * dual(ComplexMap) -- the dual of a map of
        complexes
      * "extend(Complex,Complex,Matrix)" -- see
        extend(Complex,Complex,Matrix,Sequence),
        -- extend a map of
        modules to a map of chain complexes
      * extend(Complex,Complex,Matrix,Sequence)
        -- extend a map of
        modules to a map of chain complexes
      * "freeResolution(Ideal)" -- see freeResolution, --
        compute a free resolution of a module or ideal
      * "freeResolution(Module)" -- see freeResolution,
        -- compute a free resolution of a module or ideal
      * "freeResolution(MonomialIdeal)" -- see freeResolution,
        -- compute a free resolution of a module or ideal
      * freeResolution(Matrix) -- compute
        the induced map between free resolutions
      * gradedModule(Complex) -- a new
        complex in which the differential is zero
      * HH Complex -- homology of a complex
      * HH ComplexMap -- induced map on homology or
        cohomology
      * "HH^ZZ ComplexMap" -- see HH ComplexMap, --
        induced map on homology or cohomology
      * "HH_ZZ ComplexMap" -- see HH ComplexMap, --
        induced map on homology or cohomology
      * "HH^ZZ Complex" -- see HH_ZZ Complex, --
        homology or cohomology module of a complex
      * HH_ZZ Complex -- homology or cohomology module
        of a complex
      * Hom(Complex,Complex) -- the complex
        of homomorphisms between two complexes
      * "Hom(Complex,Module)" -- see Hom(Complex,Complex),
        -- the complex of homomorphisms between two
        complexes
      * "Hom(Complex,Ring)" -- see Hom(Complex,Complex),
        -- the complex of homomorphisms between two
        complexes
      * "Hom(Module,Complex)" -- see Hom(Complex,Complex),
        -- the complex of homomorphisms between two
        complexes
      * "Hom(Ring,Complex)" -- see Hom(Complex,Complex),
        -- the complex of homomorphisms between two
        complexes
      * "Hom(Complex,ComplexMap)" -- see Hom(ComplexMap,ComplexMap),
        -- the map of complexes between Hom
        complexes
      * "Hom(Complex,Matrix)" -- see Hom(ComplexMap,ComplexMap),
        -- the map of complexes between Hom
        complexes
      * "Hom(ComplexMap,Complex)" -- see Hom(ComplexMap,ComplexMap),
        -- the map of complexes between Hom
        complexes
      * Hom(ComplexMap,ComplexMap), --
        the map of complexes between Hom complexes
      * "Hom(ComplexMap,Matrix)" -- see Hom(ComplexMap,ComplexMap),
        -- the map of complexes between Hom
        complexes
      * "Hom(ComplexMap,Module)" -- see Hom(ComplexMap,ComplexMap),
        -- the map of complexes between Hom
        complexes
      * "Hom(ComplexMap,Ring)" -- see Hom(ComplexMap,ComplexMap),
        -- the map of complexes between Hom
        complexes
      * "Hom(Matrix,Complex)" -- see Hom(ComplexMap,ComplexMap),
        -- the map of complexes between Hom
        complexes
      * "Hom(Matrix,ComplexMap)" -- see Hom(ComplexMap,ComplexMap),
        -- the map of complexes between Hom
        complexes
      * "Hom(Module,ComplexMap)" -- see Hom(ComplexMap,ComplexMap),
        -- the map of complexes between Hom
        complexes
      * "Hom(Ring,ComplexMap)" -- see Hom(ComplexMap,ComplexMap),
        -- the map of complexes between Hom
        complexes
      * homomorphism'(ComplexMap) -- get
        the element of Hom from a map of complexes
      * homomorphism(ComplexMap) -- get
        the homomorphism from an element of Hom
      * homomorphism(ZZ,Matrix,Complex)
        -- get the homomorphism from
        an element of Hom
      * horseshoeResolution(Complex),
        -- make the horseshoe resolution
      * "horseshoeResolution(Matrix,Matrix)" -- see
        horseshoeResolution(Complex), -- make
        the horseshoe resolution
      * image(ComplexMap) -- make the image of a
        map of complexes
      * inducedMap(Complex,Complex),
        -- make the map of complexes induced at each term by the identity map
      * isCommutative(ComplexMap), --
        whether a complex map commutes with the differentials
      * isComplexMorphism(ComplexMap),
        -- whether a complex map is a morphism of complexes
      * "isExact(Complex)" -- see isExact, -- whether a complex
        is exact
      * "isExact(Complex,InfiniteNumber,InfiniteNumber)" -- see isExact,
        -- whether a complex is exact
      * "isExact(Complex,InfiniteNumber,Number)" -- see isExact,
        -- whether a complex is exact
      * "isExact(Complex,Number,InfiniteNumber)" -- see isExact,
        -- whether a complex is exact
      * "isExact(Complex,Number,Number)" -- see isExact, --
        whether a complex is exact
      * isFree(Complex) -- whether a complex
        consists of free modules
      * isHomogeneous(Complex) -- whether a
        complex is homogeneous
      * isHomogeneous(ComplexMap), --
        whether a map of complexes is homogeneous
      * isNullHomotopic(ComplexMap), --
        whether a map of complexes is null-homotopic
      * isNullHomotopyOf(ComplexMap,ComplexMap)
        -- whether the first map
        of chain complexes is a null homotopy for the second
      * isQuasiIsomorphism(ComplexMap)
        -- whether a map of complexes is a
        quasi-isomorphism
      * isShortExactSequence(Complex),
        -- whether a chain complex is a short exact sequence
      * isShortExactSequence(ComplexMap,ComplexMap)
        -- whether a pair of
        complex maps forms a short exact sequence
      * isShortExactSequence(Matrix,Matrix)
        -- whether a pair of
        matrices forms a short exact sequence
      * isWellDefined(Complex) -- whether a
        complex is well-defined
      * isWellDefined(ComplexMap), --
        whether a map of chain complexes is well-defined
      * kernel(ComplexMap) -- make the kernel of
        a map of complexes
      * "koszulComplex(List)" -- see koszulComplex(Matrix),
        -- makes the Koszul complex
      * koszulComplex(Matrix) -- makes the
        Koszul complex
      * length(Complex) -- length of a complex
      * "ComplexMap // ComplexMap" -- see
        liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap),
        -- lift a
        map of chain complexes along a quasi-isomorphism
      * "homotopyMap(ComplexMap)" -- see
        liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap),
        -- lift a
        map of chain complexes along a quasi-isomorphism
      * liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap)
        -- lift a
        map of chain complexes along a quasi-isomorphism
      * "quotient(ComplexMap,ComplexMap)" -- see
        liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap),
        -- lift a
        map of chain complexes along a quasi-isomorphism
      * longExactSequence(ComplexMap,ComplexMap)
        -- make the long exact
        sequence in homology
      * map(Complex,Complex,ComplexMap)
        -- make a new map of chain
        complexes from an existing one
      * map(Complex,Complex,Function)
        -- make a map of chain complexes
      * map(Complex,Complex,HashTable)
        -- make a map of chain
        complexes
      * map(Complex,Complex,List), --
        make a map of chain complexes
      * map(Complex,Complex,ZZ) -- make
        the zero map or identity between chain complexes
      * minimalPresentation(Complex),
        -- minimal presentation of all terms in a complex
      * "minimalPresentation(ComplexMap)" -- see
        minimalPresentation(Complex), --
        minimal presentation of all terms in a complex
      * "prune(Complex)" -- see minimalPresentation(Complex),
        -- minimal presentation of all terms
        in a complex
      * "prune(ComplexMap)" -- see minimalPresentation(Complex),
        -- minimal presentation of all terms
        in a complex
      * minimize(Complex) -- a quasi-isomorphic
        complex whose terms have minimal rank
      * "naiveTruncation(Complex,InfiniteNumber,InfiniteNumber)" -- see
        naiveTruncation(Complex,ZZ,ZZ),
        -- drops all terms of a complex outside a given interval
      * "naiveTruncation(Complex,InfiniteNumber,ZZ)" -- see
        naiveTruncation(Complex,ZZ,ZZ),
        -- drops all terms of a complex outside a given interval
      * "naiveTruncation(Complex,Nothing,ZZ)" -- see
        naiveTruncation(Complex,ZZ,ZZ),
        -- drops all terms of a complex outside a given interval
      * "naiveTruncation(Complex,Sequence)" -- see
        naiveTruncation(Complex,ZZ,ZZ),
        -- drops all terms of a complex outside a given interval
      * "naiveTruncation(Complex,ZZ,InfiniteNumber)" -- see
        naiveTruncation(Complex,ZZ,ZZ),
        -- drops all terms of a complex outside a given interval
      * "naiveTruncation(Complex,ZZ,Nothing)" -- see
        naiveTruncation(Complex,ZZ,ZZ),
        -- drops all terms of a complex outside a given interval
      * naiveTruncation(Complex,ZZ,ZZ)
        -- drops all terms of a complex
        outside a given interval
      * "naiveTruncation(ComplexMap,InfiniteNumber,InfiniteNumber)" -- see
        naiveTruncation(ComplexMap,ZZ,ZZ),
        -- drops all terms in the
        source of a complex outside a given interval
      * "naiveTruncation(ComplexMap,InfiniteNumber,ZZ)" -- see
        naiveTruncation(ComplexMap,ZZ,ZZ),
        -- drops all terms in the
        source of a complex outside a given interval
      * "naiveTruncation(ComplexMap,Nothing,ZZ)" -- see
        naiveTruncation(ComplexMap,ZZ,ZZ),
        -- drops all terms in the
        source of a complex outside a given interval
      * "naiveTruncation(ComplexMap,Sequence)" -- see
        naiveTruncation(ComplexMap,ZZ,ZZ),
        -- drops all terms in the
        source of a complex outside a given interval
      * "naiveTruncation(ComplexMap,Sequence,Sequence)" -- see
        naiveTruncation(ComplexMap,ZZ,ZZ),
        -- drops all terms in the
        source of a complex outside a given interval
      * "naiveTruncation(ComplexMap,ZZ,InfiniteNumber)" -- see
        naiveTruncation(ComplexMap,ZZ,ZZ),
        -- drops all terms in the
        source of a complex outside a given interval
      * "naiveTruncation(ComplexMap,ZZ,Nothing)" -- see
        naiveTruncation(ComplexMap,ZZ,ZZ),
        -- drops all terms in the
        source of a complex outside a given interval
      * naiveTruncation(ComplexMap,ZZ,ZZ)
        -- drops all terms in the
        source of a complex outside a given interval
      * nullHomotopy(ComplexMap) -- a map
        which is a candidate for being a null homotopy
      * part(List,Complex) -- extract a graded
        component of a complex
      * "part(ZZ,Complex)" -- see part(List,Complex),
        -- extract a graded component of a complex
      * part(List,ComplexMap) -- extract a
        graded component of a map of complexes
      * "part(ZZ,ComplexMap)" -- see part(List,ComplexMap),
        -- extract a graded component of a map of
        complexes
      * poincare(Complex) -- assemble degrees of
        a chain complex into a polynomial
      * poincareN(Complex) -- assemble degrees
        of a chain complex into a polynomial
      * randomComplexMap(Complex,Complex)
        -- a random map of chain
        complexes
      * regularity(Complex) -- compute the
        Castelnuovo-Mumford regularity
      * resolution(Complex) -- minimal free
        resolution of a complex
      * "resolutionMap(Complex)" -- see resolutionMap, --
        map from a free resolution to the given complex
      * ring(Complex) -- access the ring of a complex
        or a complex map
      * "ring(ComplexMap)" -- see ring(Complex), --
        access the ring of a complex or a complex map
      * "Complex ** Ring" -- see RingMap ** Complex,
        -- tensor a complex along a ring map
      * "Complex ** RingMap" -- see RingMap ** Complex,
        -- tensor a complex along a ring map
      * "Ring ** Complex" -- see RingMap ** Complex,
        -- tensor a complex along a ring map
      * RingMap ** Complex -- tensor a complex
        along a ring map
      * "tensor(Complex,RingMap)" -- see RingMap ** Complex,
        -- tensor a complex along a ring map
      * "tensor(RingMap,Complex)" -- see RingMap ** Complex,
        -- tensor a complex along a ring map
      * "ComplexMap ** Ring" -- see RingMap ** ComplexMap,
        -- tensor a map of complexes along a ring map
      * "ComplexMap ** RingMap" -- see RingMap ** ComplexMap,
        -- tensor a map of complexes along a ring map
      * "Ring ** ComplexMap" -- see RingMap ** ComplexMap,
        -- tensor a map of complexes along a ring map
      * RingMap ** ComplexMap -- tensor a map
        of complexes along a ring map
      * "tensor(ComplexMap,RingMap)" -- see RingMap ** ComplexMap,
        -- tensor a map of complexes along a ring
        map
      * "tensor(RingMap,ComplexMap)" -- see RingMap ** ComplexMap,
        -- tensor a map of complexes along a ring
        map
      * RingMap Complex -- apply a ring map
      * RingMap ComplexMap -- apply a ring map to a
        map of complexes
      * source(ComplexMap) -- get the source of
        a map of chain complexes
      * sum(Complex) -- make the direct sum of all
        terms
      * "sum(ComplexMap)" -- see sum(Complex), -- make
        the direct sum of all terms
      * target(ComplexMap) -- get the target of
        a map of chain complexes
      * tensorAssociativity(Complex,Complex,Complex)
        -- make the
        canonical isomorphism arising from associativity
      * tensorCommutativity(Complex,Complex)
        -- make the canonical
        isomorphism arising from commutativity
      * tensorCommutativity(Module,Module)
        -- make the canonical
        isomorphism arising from commutativity
      * Tor_ZZ(Matrix,Module) -- make the
        induced map on Tor modules
      * "Tor_ZZ(Module,Matrix)" -- see Tor_ZZ(Matrix,Module),
        -- make the induced map on Tor modules
      * torSymmetry(ZZ,Module,Module)
        -- makes the canonical
        isomorphism realizing the symmetry of Tor
      * truncate(List,Complex), --
        truncation of a complex at a specified degree or set of degrees
      * "truncate(ZZ,Complex)" -- see truncate(List,Complex),
        -- truncation of a complex at a specified
        degree or set of degrees
      * truncate(List,ComplexMap), --
        truncation of a complex map at a specified degree or set of degrees
      * "truncate(ZZ,ComplexMap)" -- see truncate(List,ComplexMap),
        -- truncation of a complex map at a
        specified degree or set of degrees
      * yonedaExtension'(Complex), --
        identifies the element of Ext corresponding to an extension
      * yonedaExtension(Matrix) -- creates
        a chain complex representing an extension of modules
      * yonedaMap'(ComplexMap) -- identifies
        the element of Ext corresponding to a map of free resolutions
      * yonedaMap(Matrix) -- creates a chain
        complex map representing an extension of modules
      * yonedaProduct(Matrix,Matrix),
        -- make the product of two elements in Ext modules
      * yonedaProduct(Module,Module),
        -- make the product map between Ext modules
  * Symbols
      * "UseTarget" -- see canonicalMap, -- gets the
        natural map arising from various constructions
      * "Base" -- see complex, -- make a chain complex
      * Concentration -- optional argument used to
        specify the concentration
      * "minimizingMap" -- see minimize(Complex),
        -- a quasi-isomorphic complex whose terms have minimal rank
      * "Boundary" -- see randomComplexMap(Complex,Complex),
        -- a random map of chain
        complexes
      * "Cycle" -- see randomComplexMap(Complex,Complex),
        -- a random map of chain
        complexes
      * "InternalDegree" -- see randomComplexMap(Complex,Complex),
        -- a random map of chain
        complexes

For the programmer
==================

The object Complexes, is a package (Macaulay2Doc).

arithmetic with complex maps -- perform arithmetic operations on complex maps
*****************************************************************************

Synopsis
========

  * Usage:
        f + g
        a + f
        f + a
        -f
        f - g
        a - f
        f - a
        a * f
  * Inputs:
      * f, a map of complexes,
      * g, a map of complexes,
      * a, a ring element (Macaulay2Doc), that is, an
        element in the underlying ring or a number
  * Outputs:
      * a map of complexes,

The set of complex maps forms a module over the underlying ring.
These methods implement the basic operations of addition,
subtraction, and scalar multiplication.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a..d];                                                       |
+-----------------------------------------------------------------------------+
|i2 : C = freeResolution coker matrix{{a*b, a*c^2, b*c*d^3, a^3}}             |
|                                                                             |
|      1      4      4      1                                                 |
|o2 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : D = freeResolution coker matrix{{a*b, a*c^2, b*c*d^3, a^3, a*c*d}}      |
|                                                                             |
|      1      5      7      4      1                                          |
|o3 = R  <-- R  <-- R  <-- R  <-- R                                           |
|                                                                             |
|     0      1      2      3      4                                           |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : f = randomComplexMap(D, C, Cycle => true)                               |
|                                                                             |
|          1               1                                                  |
|o4 = 0 : R  <----------- R  : 0                                              |
|               | -47 |                                                       |
|                                                                             |
|          5                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {2} | -47 0   0   24a3-36a2b-30a2c+19ac2+19bc2-10c3-29a2d-8acd|
|               {3} | 0   -47 0   -24ab+36b2+30bc+18c2+29bd+15cd              |
|               {3} | 0   0   -47 -18a2-19ab-19b2+10bc-8ad-5bd-19cd+47d2      |
|               {3} | 0   0   0   -15a2+8ab+22b2+8ac-38bc+19c2+24bd-47cd      |
|               {5} | 0   0   0   -47                                         |
|                                                                             |
|          7                                                                  |
|     2 : R  <----------------------------------------------------------------|
|               {4} | -47 0   0    -24a2+36ab+30ac+39c2+29ad+43cd           | |
|               {4} | 0   -47 -28d 43a2-19ab+10ac+29ad-38bd-16cd+39d2       | |
|               {4} | 0   0   28c  -35a2+22ab+29ac+38bc+16c2+24ad-39cd-47d2 | |
|               {4} | 0   0   -28b 21a2+34ab-38b2+19ac-16bc-47ad+39bd       | |
|               {5} | 0   0   -47  -18a+39b+13d                             | |
|               {5} | 0   0   0    -15a+43b-13c                             | |
|               {6} | 0   0   0    -47                                      | |
|                                                                             |
|          4                    1                                             |
|     3 : R  <---------------- R  : 3                                         |
|               {5} | -28b |                                                  |
|               {6} | -47  |                                                  |
|               {6} | 0    |                                                  |
|               {6} | 0    |                                                  |
|                                                                             |
|o4 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                        4                                                    |
|---------------------- R  : 1                                                |
|-22bcd+43c2d-24cd2 |                                                         |
|                   |                                                         |
|                   |                                                         |
|                   |                                                         |
|                   |                                                         |
|                                                                             |
|   4                                                                         |
|- R  : 2                                                                     |
+-----------------------------------------------------------------------------+
|i5 : g = randomComplexMap(D, C, Boundary => true)                            |
|                                                                             |
|          1         1                                                        |
|o5 = 0 : R  <----- R  : 0                                                    |
|               0                                                             |
|                                                                             |
|          5                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {2} | 0 0 0 -38a3-2a2b-16a2c-45ac2+34bc2+48c3-22a2d-47acd-19bc|
|               {3} | 0 0 0 38ab+2b2+16bc+17c2+22bd+11cd                      |
|               {3} | 0 0 0 -17a2+45ab-34b2-48bc-15ad-24bd-39cd-43d2          |
|               {3} | 0 0 0 -11a2+47ab+19b2+15ac-39bc+39c2+7bd+43cd           |
|               {5} | 0 0 0 0                                                 |
|                                                                             |
|          7                                                            4     |
|     2 : R  <-------------------------------------------------------- R  : 2 |
|               {4} | 0 0 0    38a2+2ab+16ac-38c2+22ad+33cd        |          |
|               {4} | 0 0 48d  -18a2-34ab-48ac-47ad+36bd+35cd+11d2 |          |
|               {4} | 0 0 -48c 14a2+19ab-16ac-36bc-35c2+7ad-11cd   |          |
|               {4} | 0 0 48b  -25a2-23ab+36b2+39ac+35bc+43ad+11bd |          |
|               {5} | 0 0 0    -17a-38b-40d                        |          |
|               {5} | 0 0 0    -11a+33b+40c                        |          |
|               {6} | 0 0 0    0                                   |          |
|                                                                             |
|          4                   1                                              |
|     3 : R  <--------------- R  : 3                                          |
|               {5} | 48b |                                                   |
|               {6} | 0   |                                                   |
|               {6} | 0   |                                                   |
|               {6} | 0   |                                                   |
|                                                                             |
|o5 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                  4                                                          |
|---------------- R  : 1                                                      |
|d-38c2d-7cd2 |                                                               |
|             |                                                               |
|             |                                                               |
|             |                                                               |
|             |                                                               |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i6 : f+g                                                                     |
|                                                                             |
|          1               1                                                  |
|o6 = 0 : R  <----------- R  : 0                                              |
|               | -47 |                                                       |
|                                                                             |
|          5                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {2} | -47 0   0   -14a3-38a2b-46a2c-26ac2-48bc2+38c3+50a2d+46a|
|               {3} | 0   -47 0   14ab+38b2+46bc+35c2-50bd+26cd               |
|               {3} | 0   0   -47 -35a2+26ab+48b2-38bc-23ad-29bd+43cd+4d2     |
|               {3} | 0   0   0   -26a2-46ab+41b2+23ac+24bc-43c2+31bd-4cd     |
|               {5} | 0   0   0   -47                                         |
|                                                                             |
|          7                                                                  |
|     2 : R  <----------------------------------------------------------------|
|               {4} | -47 0   0    14a2+38ab+46ac+c2-50ad-25cd             |  |
|               {4} | 0   -47 20d  25a2+48ab-38ac-18ad-2bd+19cd+50d2       |  |
|               {4} | 0   0   -20c -21a2+41ab+13ac+2bc-19c2+31ad-50cd-47d2 |  |
|               {4} | 0   0   20b  -4a2+11ab-2b2-43ac+19bc-4ad+50bd        |  |
|               {5} | 0   0   -47  -35a+b-27d                              |  |
|               {5} | 0   0   0    -26a-25b+27c                            |  |
|               {6} | 0   0   0    -47                                     |  |
|                                                                             |
|          4                   1                                              |
|     3 : R  <--------------- R  : 3                                          |
|               {5} | 20b |                                                   |
|               {6} | -47 |                                                   |
|               {6} | 0   |                                                   |
|               {6} | 0   |                                                   |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                         4                                                   |
|----------------------- R  : 1                                               |
|cd-41bcd+5c2d-31cd2 |                                                        |
|                    |                                                        |
|                    |                                                        |
|                    |                                                        |
|                    |                                                        |
|                                                                             |
|  4                                                                          |
| R  : 2                                                                      |
+-----------------------------------------------------------------------------+
|i7 : f-g                                                                     |
|                                                                             |
|          1               1                                                  |
|o7 = 0 : R  <----------- R  : 0                                              |
|               | -47 |                                                       |
|                                                                             |
|          5                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {2} | -47 0   0   -39a3-34a2b-14a2c-37ac2-15bc2+43c3-7a2d+39ac|
|               {3} | 0   -47 0   39ab+34b2+14bc+c2+7bd+4cd                   |
|               {3} | 0   0   -47 -a2+37ab+15b2-43bc+7ad+19bd+20cd-11d2       |
|               {3} | 0   0   0   -4a2-39ab+3b2-7ac+bc-20c2+17bd+11cd         |
|               {5} | 0   0   0   -47                                         |
|                                                                             |
|          7                                                                  |
|     2 : R  <----------------------------------------------------------------|
|               {4} | -47 0   0    39a2+34ab+14ac-24c2+7ad+10cd            |  |
|               {4} | 0   -47 25d  -40a2+15ab-43ac-25ad+27bd+50cd+28d2     |  |
|               {4} | 0   0   -25c -49a2+3ab+45ac-27bc-50c2+17ad-28cd-47d2 |  |
|               {4} | 0   0   25b  46a2-44ab+27b2-20ac+50bc+11ad+28bd      |  |
|               {5} | 0   0   -47  -a-24b-48d                              |  |
|               {5} | 0   0   0    -4a+10b+48c                             |  |
|               {6} | 0   0   0    -47                                     |  |
|                                                                             |
|          4                   1                                              |
|     3 : R  <--------------- R  : 3                                          |
|               {5} | 25b |                                                   |
|               {6} | -47 |                                                   |
|               {6} | 0   |                                                   |
|               {6} | 0   |                                                   |
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                        4                                                    |
|---------------------- R  : 1                                                |
|d-3bcd-20c2d-17cd2 |                                                         |
|                   |                                                         |
|                   |                                                         |
|                   |                                                         |
|                   |                                                         |
|                                                                             |
|  4                                                                          |
| R  : 2                                                                      |
+-----------------------------------------------------------------------------+
|i8 : -f                                                                      |
|                                                                             |
|          1              1                                                   |
|o8 = 0 : R  <---------- R  : 0                                               |
|               | 47 |                                                        |
|                                                                             |
|          5                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {2} | 47 0  0  -24a3+36a2b+30a2c-19ac2-19bc2+10c3+29a2d+8acd+2|
|               {3} | 0  47 0  24ab-36b2-30bc-18c2-29bd-15cd                  |
|               {3} | 0  0  47 18a2+19ab+19b2-10bc+8ad+5bd+19cd-47d2          |
|               {3} | 0  0  0  15a2-8ab-22b2-8ac+38bc-19c2-24bd+47cd          |
|               {5} | 0  0  0  47                                             |
|                                                                             |
|          7                                                                  |
|     2 : R  <-------------------------------------------------------------- R|
|               {4} | 47 0  0    24a2-36ab-30ac-39c2-29ad-43cd           |    |
|               {4} | 0  47 28d  -43a2+19ab-10ac-29ad+38bd+16cd-39d2     |    |
|               {4} | 0  0  -28c 35a2-22ab-29ac-38bc-16c2-24ad+39cd+47d2 |    |
|               {4} | 0  0  28b  -21a2-34ab+38b2-19ac+16bc+47ad-39bd     |    |
|               {5} | 0  0  47   18a-39b-13d                             |    |
|               {5} | 0  0  0    15a-43b+13c                             |    |
|               {6} | 0  0  0    47                                      |    |
|                                                                             |
|          4                   1                                              |
|     3 : R  <--------------- R  : 3                                          |
|               {5} | 28b |                                                   |
|               {6} | 47  |                                                   |
|               {6} | 0   |                                                   |
|               {6} | 0   |                                                   |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                      4                                                      |
|-------------------- R  : 1                                                  |
|2bcd-43c2d+24cd2 |                                                           |
|                 |                                                           |
|                 |                                                           |
|                 |                                                           |
|                 |                                                           |
|                                                                             |
|4                                                                            |
|  : 2                                                                        |
+-----------------------------------------------------------------------------+
|i9 : 3*f                                                                     |
|                                                                             |
|          1               1                                                  |
|o9 = 0 : R  <----------- R  : 0                                              |
|               | -40 |                                                       |
|                                                                             |
|          5                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {2} | -40 0   0   -29a3-7a2b+11a2c-44ac2-44bc2-30c3+14a2d-24ac|
|               {3} | 0   -40 0   29ab+7b2-11bc-47c2-14bd+45cd                |
|               {3} | 0   0   -40 47a2+44ab+44b2+30bc-24ad-15bd+44cd+40d2     |
|               {3} | 0   0   0   -45a2+24ab-35b2+24ac-13bc-44c2-29bd-40cd    |
|               {5} | 0   0   0   -40                                         |
|                                                                             |
|          7                                                                  |
|     2 : R  <----------------------------------------------------------------|
|               {4} | -40 0   0    29a2+7ab-11ac+16c2-14ad+28cd            |  |
|               {4} | 0   -40 17d  28a2+44ab+30ac-14ad-13bd-48cd+16d2      |  |
|               {4} | 0   0   -17c -4a2-35ab-14ac+13bc+48c2-29ad-16cd-40d2 |  |
|               {4} | 0   0   17b  -38a2+ab-13b2-44ac-48bc-40ad+16bd       |  |
|               {5} | 0   0   -40  47a+16b+39d                             |  |
|               {5} | 0   0   0    -45a+28b-39c                            |  |
|               {6} | 0   0   0    -40                                     |  |
|                                                                             |
|          4                   1                                              |
|     3 : R  <--------------- R  : 3                                          |
|               {5} | 17b |                                                   |
|               {6} | -40 |                                                   |
|               {6} | 0   |                                                   |
|               {6} | 0   |                                                   |
|                                                                             |
|o9 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                         4                                                   |
|----------------------- R  : 1                                               |
|d+35bcd+28c2d+29cd2 |                                                        |
|                    |                                                        |
|                    |                                                        |
|                    |                                                        |
|                    |                                                        |
|                                                                             |
|  4                                                                          |
| R  : 2                                                                      |
+-----------------------------------------------------------------------------+
|i10 : 0*f                                                                    |
|                                                                             |
|o10 = 0                                                                      |
|                                                                             |
|o10 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i11 : a*f                                                                    |
|                                                                             |
|           1                1                                                |
|o11 = 0 : R  <------------ R  : 0                                            |
|                | -47a |                                                     |
|                                                                             |
|           5                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {2} | -47a 0    0    24a4-36a3b-30a3c+19a2c2+19abc2-10ac3-29a|
|                {3} | 0    -47a 0    -24a2b+36ab2+30abc+18ac2+29abd+15acd    |
|                {3} | 0    0    -47a -18a3-19a2b-19ab2+10abc-8a2d-5abd-19acd+|
|                {3} | 0    0    0    -15a3+8a2b+22ab2+8a2c-38abc+19ac2+24abd-|
|                {5} | 0    0    0    -47a                                    |
|                                                                             |
|           7                                                                 |
|      2 : R  <---------------------------------------------------------------|
|                {4} | -47a 0    0     -24a3+36a2b+30a2c+39ac2+29a2d+43acd    |
|                {4} | 0    -47a -28ad 43a3-19a2b+10a2c+29a2d-38abd-16acd+39ad|
|                {4} | 0    0    28ac  -35a3+22a2b+29a2c+38abc+16ac2+24a2d-39a|
|                {4} | 0    0    -28ab 21a3+34a2b-38ab2+19a2c-16abc-47a2d+39ab|
|                {5} | 0    0    -47a  -18a2+39ab+13ad                        |
|                {5} | 0    0    0     -15a2+43ab-13ac                        |
|                {6} | 0    0    0     -47a                                   |
|                                                                             |
|           4                     1                                           |
|      3 : R  <----------------- R  : 3                                       |
|                {5} | -28ab |                                                |
|                {6} | -47a  |                                                |
|                {6} | 0     |                                                |
|                {6} | 0     |                                                |
|                                                                             |
|o11 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                   4                                         |
|--------------------------------- R  : 1                                     |
|3d-8a2cd-22abcd+43ac2d-24acd2 |                                              |
|                              |                                              |
|47ad2                         |                                              |
|47acd                         |                                              |
|                              |                                              |
|                                                                             |
|              4                                                              |
|------------ R  : 2                                                          |
|         |                                                                   |
|2        |                                                                   |
|cd-47ad2 |                                                                   |
|d        |                                                                   |
|         |                                                                   |
|         |                                                                   |
|         |                                                                   |
+-----------------------------------------------------------------------------+
|i12 : assert(0*f == 0)                                                       |
+-----------------------------------------------------------------------------+
|i13 : assert(1*f == f)                                                       |
+-----------------------------------------------------------------------------+
|i14 : assert((-1)*f == -f)                                                   |
+-----------------------------------------------------------------------------+
|i15 : assert(-(f-g) == g-f)                                                  |
+-----------------------------------------------------------------------------+
|i16 : assert((a+b)*f == a*f + b*f)                                           |
+-----------------------------------------------------------------------------+
|i17 : assert(a*(f+g) == a*f + a*g)                                           |
+-----------------------------------------------------------------------------+
|i18 : assert isComplexMorphism (f+g)                                         |
+-----------------------------------------------------------------------------+

Adding or subtracting a scalar is the same as adding or subtracting the scalar
multiple of the identity.  In particular, the source and target must be equal.

+-----------------------------------------------------------------------------+
|i19 : h = randomComplexMap(C, C)                                             |
|                                                                             |
|           1              1                                                  |
|o19 = 0 : R  <---------- R  : 0                                              |
|                | 11 |                                                       |
|                                                                             |
|           4                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {2} | 46 -28a+b-3c+22d -7a+2b+29c-47d -13a3-10a2b+39ab2-20b3+|
|                {3} | 0  -47           15             -19a2+17ab-39b2-20ac+36|
|                {3} | 0  -23           -37            -26a2+22ab-8b2-49ac+43b|
|                {5} | 0  0             0              -30                    |
|                                                                             |
|           4                                                                 |
|      2 : R  <---------------------------------------------------------------|
|                {4} | 41 -28 35a-9b-35c+6d  -41a2-49ab+30b2-13ac-47bc-40c2+4a|
|                {4} | 16 -6  40a+3b-31c+25d -31a2-39ab-29b2-31ac-48bc-37c2-48|
|                {5} | 0  0   -2             28a-18b+46c+d                    |
|                {6} | 0  0   0              40                               |
|                                                                             |
|           1                   1                                             |
|      3 : R  <--------------- R  : 3                                         |
|                {6} | -22 |                                                  |
|                                                                             |
|o19 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|30a2c+27abc+24b2c+32ac2-48bc2-18a2d-22abd-30b2d-9acd-15bcd+33c2d-32ad2+39bd2-|
|bc-39c2+44ad+9bd+4cd+13d2                                                    |
|c+36c2-11ad-8bd-3cd-22d2                                                     |
|                                                                             |
|                                                                             |
|                       4                                                     |
|--------------------- R  : 2                                                 |
|d+27bd+37cd-35d2  |                                                          |
|ad+30bd+47cd-49d2 |                                                          |
|                  |                                                          |
|                  |                                                          |
|-----------------------------------------------------------------------------|
|                4                                                            |
|-------------- R  : 1                                                        |
|49cd2-33d3 |                                                                 |
|           |                                                                 |
|           |                                                                 |
|           |                                                                 |
+-----------------------------------------------------------------------------+
|i20 : h+1                                                                    |
|                                                                             |
|           1              1                                                  |
|o20 = 0 : R  <---------- R  : 0                                              |
|                | 12 |                                                       |
|                                                                             |
|           4                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {2} | 47 -28a+b-3c+22d -7a+2b+29c-47d -13a3-10a2b+39ab2-20b3+|
|                {3} | 0  -46           15             -19a2+17ab-39b2-20ac+36|
|                {3} | 0  -23           -36            -26a2+22ab-8b2-49ac+43b|
|                {5} | 0  0             0              -29                    |
|                                                                             |
|           4                                                                 |
|      2 : R  <---------------------------------------------------------------|
|                {4} | 42 -28 35a-9b-35c+6d  -41a2-49ab+30b2-13ac-47bc-40c2+4a|
|                {4} | 16 -5  40a+3b-31c+25d -31a2-39ab-29b2-31ac-48bc-37c2-48|
|                {5} | 0  0   -1             28a-18b+46c+d                    |
|                {6} | 0  0   0              41                               |
|                                                                             |
|           1                   1                                             |
|      3 : R  <--------------- R  : 3                                         |
|                {6} | -21 |                                                  |
|                                                                             |
|o20 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|30a2c+27abc+24b2c+32ac2-48bc2-18a2d-22abd-30b2d-9acd-15bcd+33c2d-32ad2+39bd2-|
|bc-39c2+44ad+9bd+4cd+13d2                                                    |
|c+36c2-11ad-8bd-3cd-22d2                                                     |
|                                                                             |
|                                                                             |
|                       4                                                     |
|--------------------- R  : 2                                                 |
|d+27bd+37cd-35d2  |                                                          |
|ad+30bd+47cd-49d2 |                                                          |
|                  |                                                          |
|                  |                                                          |
|-----------------------------------------------------------------------------|
|                4                                                            |
|-------------- R  : 1                                                        |
|49cd2-33d3 |                                                                 |
|           |                                                                 |
|           |                                                                 |
|           |                                                                 |
+-----------------------------------------------------------------------------+
|i21 : assert(h+1 == h + id_C)                                                |
+-----------------------------------------------------------------------------+
|i22 : assert(h+a == h + a*id_C)                                              |
+-----------------------------------------------------------------------------+
|i23 : assert(1-h == id_C - h)                                                |
+-----------------------------------------------------------------------------+
|i24 : assert(b-c*h == -c*h + b*id_C)                                         |
+-----------------------------------------------------------------------------+
|i25 : assert(b-h*c == -h*c + id_C*b)                                         |
+-----------------------------------------------------------------------------+

Arithmetic on differentials can be a useful method for constructing new chain
complexes.

+--------------------------------------+
|i26 : E = complex(-dd^C)              |
|                                      |
|       1      4      4      1         |
|o26 = R  <-- R  <-- R  <-- R          |
|                                      |
|      0      1      2      3          |
|                                      |
|o26 : Complex                         |
+--------------------------------------+
|i27 : isWellDefined E                 |
|                                      |
|o27 = true                            |
+--------------------------------------+
|i28 : assert(dd^E == map(E, E, -dd^C))|
+--------------------------------------+

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * randomComplexMap -- a
    random map of chain complexes
  * complex(ComplexMap) -- make a complex by
    specifying the differential
  * map(Complex,Complex,ComplexMap)
    -- make a new map of chain
    complexes from an existing one

augmentationMap -- map from a free resolution to a module regarded as a complex
*******************************************************************************

Synopsis
========

  * Usage:
        augmentationMap C
  * Inputs:
      * C, a complex, constructed via freeResolution,
  * Outputs:
      * a map of complexes, a quasi-isomorphism whose source
        is $C$ and whose target is the module resolved by $C$

Description
===========

Given a complex $C$, this method produces the natural quasi-isomorphism from a
complex $F$ all of whose terms are free modules to the complex $C$. The
algorithm used minimizes the ranks of the free modules in $F$.

+------------------------------------------------+
|i1 : R = ZZ/101[a,b,c];                         |
+------------------------------------------------+
|i2 : I = ideal(a^2, a*b, b*c)                   |
|                                                |
|             2                                  |
|o2 = ideal (a , a*b, b*c)                       |
|                                                |
|o2 : Ideal of R                                 |
+------------------------------------------------+
|i3 : C = freeResolution I                       |
|                                                |
|      1      3      2                           |
|o3 = R  <-- R  <-- R                            |
|                                                |
|     0      1      2                            |
|                                                |
|o3 : Complex                                    |
+------------------------------------------------+
|i4 : f = augmentationMap C                      |
|                                                |
|                                           1    |
|o4 = 0 : cokernel | a2 ab bc | <--------- R  : 0|
|                                  | 1 |         |
|                                                |
|o4 : ComplexMap                                 |
+------------------------------------------------+
|i5 : assert isWellDefined f                     |
+------------------------------------------------+
|i6 : assert isComplexMorphism f                 |
+------------------------------------------------+
|i7 : assert isQuasiIsomorphism f                |
+------------------------------------------------+
+------------------------------------------------+
|i8 : g = resolutionMap complex comodule I       |
|                                                |
|                                           1    |
|o8 = 0 : cokernel | a2 ab bc | <--------- R  : 0|
|                                  | 1 |         |
|                                                |
|o8 : ComplexMap                                 |
+------------------------------------------------+
|i9 : assert(f == g)                             |
+------------------------------------------------+

See also
========

  * resolutionMap(Complex) -- map from a free resolution
    to the given complex
  * freeResolution(Module) -- compute a free resolution
    of a module or ideal
  * isQuasiIsomorphism(ComplexMap),
    -- whether a map of complexes is a quasi-isomorphism

Ways to use augmentationMap :
=============================

  * "augmentationMap(Complex)"

For the programmer
==================

The object augmentationMap, is a method function (Macaulay2Doc).

Basic invariants and properties -- information about accessing basic features
*****************************************************************************

Predicates for complexes and complex maps
=========================================

  * isWellDefined(Complex) -- whether a
    complex is well-defined
  * isExact(Complex) -- whether a complex is exact
  * isHomogeneous(Complex) -- whether a
    complex is homogeneous
  * isFree(Complex) -- whether a complex consists
    of free modules
  * isShortExactSequence(Complex), --
    whether a chain complex is a short exact sequence
  * isWellDefined(ComplexMap) -- whether
    a map of chain complexes is well-defined
  * isCommutative(ComplexMap) -- whether
    a complex map commutes with the differentials
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes
  * isQuasiIsomorphism(ComplexMap),
    -- whether a map of complexes is a quasi-isomorphism
  * isShortExactSequence(ComplexMap,ComplexMap)
    -- whether a pair of
    complex maps forms a short exact sequence
  * isNullHomotopic(ComplexMap), --
    whether a map of complexes is null-homotopic
  * isNullHomotopyOf(ComplexMap,ComplexMap)
    -- whether the first map of
    chain complexes is a null homotopy for the second

Other invariants for complexes
==============================

  * ring(Complex) -- access the ring of a complex or
    a complex map
  * concentration(Complex) -- indices on which a complex
    may be non-zero
  * max(Complex) -- indices on which a complex may be
    non-zero
  * min(Complex) -- indices on which a complex may be
    non-zero
  * length(Complex) -- length of a complex
  * regularity(Complex) -- compute the
    Castelnuovo-Mumford regularity
  * betti(Complex) -- display of degrees in a
    complex
  * poincare(Complex) -- assemble degrees of a
    chain complex into a polynomial
  * poincareN(Complex) -- assemble degrees of a
    chain complex into a polynomial
  * components(Complex) -- list the components
    of a direct sum

Other invariants for complex maps
=================================

  * source(ComplexMap) -- get the source of a
    map of chain complexes
  * target(ComplexMap) -- get the target of a
    map of chain complexes
  * degree(ComplexMap) -- get the degree of a
    map of chain complexes
  * ring(ComplexMap) -- access the ring of a complex
    or a complex map
  * concentration(ComplexMap) -- indices
    on which a complex map may be non-zero
  * isHomogeneous(ComplexMap) -- whether
    a map of complexes is homogeneous
  * components(ComplexMap) -- list the
    components of a direct sum

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * Working with Ext -- information about functorial
    properties
  * Working with Tor -- information about functorial
    properties
  * Towards computing in the derived category

betti(Complex) -- display of degrees in a complex
*************************************************

Synopsis
========

  * Function: betti (Macaulay2Doc),
  * Usage:
        betti C
  * Inputs:
      * C, a complex,
  * Optional inputs (Macaulay2Doc),:
      * Weights (Macaulay2Doc), => a list (Macaulay2Doc),
        default value null, a list of integers whose dot
        product with the multidegree of a basis element is enumerated in the
        display returned. The default is the heft vector of the ring. See
        heft (Macaulay2Doc).
      * Minimize (Macaulay2Doc),
        => ..., default value false, null
  * Outputs:
      * a Betti tally (Macaulay2Doc), a diagram showing the
        degrees of the generators of the components in C

Description
===========

Column $j$ of the top row of the diagram gives the rank of the $j$-th component
$C_j$ of the complex $C$.  The entry in column $j$ in the row labelled $i$ is
the number of basis elements of (weighted) degree $i+j$ in $C_j$.  When the
complex is the free resolution of a module the entries are the total and the
graded Betti numbers of the module.

As a first example, we consider the ideal in 18 variables which cuts out the
variety of commuting 3 by 3 matrices.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[vars(0..17)]                                                 |
|                                                                             |
|o1 = S                                                                       |
|                                                                             |
|o1 : PolynomialRing                                                          |
+-----------------------------------------------------------------------------+
|i2 : m1 = genericMatrix(S,a,3,3)                                             |
|                                                                             |
|o2 = | a d g |                                                               |
|     | b e h |                                                               |
|     | c f i |                                                               |
|                                                                             |
|             3       3                                                       |
|o2 : Matrix S  <--- S                                                        |
+-----------------------------------------------------------------------------+
|i3 : m2 = genericMatrix(S,j,3,3)                                             |
|                                                                             |
|o3 = | j m p |                                                               |
|     | k n q |                                                               |
|     | l o r |                                                               |
|                                                                             |
|             3       3                                                       |
|o3 : Matrix S  <--- S                                                        |
+-----------------------------------------------------------------------------+
|i4 : J = ideal(m1*m2-m2*m1)                                                  |
|                                                                             |
|o4 = ideal (d*k + g*l - b*m - c*p, b*j - a*k + e*k + h*l - b*n - c*q, c*j +  |
|     ------------------------------------------------------------------------|
|     f*k - a*l + i*l - b*o - c*r, - d*j + a*m - e*m + d*n + g*o - f*p, - d*k |
|     ------------------------------------------------------------------------|
|     + b*m + h*o - f*q, - d*l + c*m + f*n - e*o + i*o - f*r, - g*j - h*m +   |
|     ------------------------------------------------------------------------|
|     a*p - i*p + d*q + g*r, - g*k - h*n + b*p + e*q - i*q + h*r, - g*l - h*o |
|     ------------------------------------------------------------------------|
|     + c*p + f*q)                                                            |
|                                                                             |
|o4 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i5 : C0 = freeResolution J                                                   |
|                                                                             |
|      1      8      33      60      61      32      5                        |
|o5 = S  <-- S  <-- S   <-- S   <-- S   <-- S   <-- S                         |
|                                                                             |
|     0      1      2       3       4       5       6                         |
|                                                                             |
|o5 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i6 : betti C0                                                                |
|                                                                             |
|            0 1  2  3  4  5 6                                                |
|o6 = total: 1 8 33 60 61 32 5                                                |
|         0: 1 .  .  .  .  . .                                                |
|         1: . 8  2  .  .  . .                                                |
|         2: . . 31 32  3  . .                                                |
|         3: . .  . 28 58 32 4                                                |
|         4: . .  .  .  .  . 1                                                |
|                                                                             |
|o6 : BettiTally                                                              |
+-----------------------------------------------------------------------------+

From the display, we see that $J$ has 8 minimal generators, all in degree 2,
and that there are 2 linear syzygies on these generators, and 31 quadratic
syzygies. Since this complex is the free resolution of $S/J$, the projective
dimension is 6, the index of the last column, and the regularity of $S/J$ is 4,
the index of the last row in the diagram.

+------------------------+
|i7 : length C0          |
|                        |
|o7 = 6                  |
+------------------------+
|i8 : pdim betti C0      |
|                        |
|o8 = 6                  |
+------------------------+
|i9 : regularity betti C0|
|                        |
|o9 = 4                  |
+------------------------+

The betti display still makes sense if the complex is not a free resolution.

+-----------------------------------------+
|i10 : betti dual C0                      |
|                                         |
|             -6 -5 -4 -3 -2 -1 0         |
|o10 = total:  5 32 61 60 33  8 1         |
|         -4:  1  .  .  .  .  . .         |
|         -3:  4 32 58 28  .  . .         |
|         -2:  .  .  3 32 31  . .         |
|         -1:  .  .  .  .  2  8 .         |
|          0:  .  .  .  .  .  . 1         |
|                                         |
|o10 : BettiTally                         |
+-----------------------------------------+
|i11 : C1 = Hom(C0, image matrix{{a,b}}); |
+-----------------------------------------+
|i12 : betti C1                           |
|                                         |
|             -6 -5  -4  -3 -2 -1 0       |
|o12 = total: 10 64 122 120 66 16 2       |
|         -3:  2  .   .   .  .  . .       |
|         -2:  8 64 116  56  .  . .       |
|         -1:  .  .   6  64 62  . .       |
|          0:  .  .   .   .  4 16 .       |
|          1:  .  .   .   .  .  . 2       |
|                                         |
|o12 : BettiTally                         |
+-----------------------------------------+
|i13 : C1_-6                              |
|                                         |
|o13 = image {-9}  | 0 0 b a 0 0 0 0 0 0 ||
|            {-9}  | 0 0 0 0 b a 0 0 0 0 ||
|            {-9}  | 0 0 0 0 0 0 b a 0 0 ||
|            {-9}  | 0 0 0 0 0 0 0 0 b a ||
|            {-10} | b a 0 0 0 0 0 0 0 0 ||
|                                         |
|                              5          |
|o13 : S-module, submodule of S           |
+-----------------------------------------+

This module has 10 generators, 2 in degree $-9=(-6)+(-3)$, and 8 in degree
$-8=(-6)+(-2)$.

In the multi-graded case, the heft vector is used, by default, as the weight
vector for weighting the components of the degree vectors of basis elements.

The following example is a nonstandard $\mathbb{Z}$-graded polynomial ring.

+--------------------------------------------+
|i14 : R = ZZ/101[a,b,c,Degrees=>{-1,-2,-3}];|
+--------------------------------------------+
|i15 : heft R                                |
|                                            |
|o15 = {-1}                                  |
|                                            |
|o15 : List                                  |
+--------------------------------------------+
|i16 : C2 = freeResolution coker vars R      |
|                                            |
|       1      3      3      1               |
|o16 = R  <-- R  <-- R  <-- R                |
|                                            |
|      0      1      2      3                |
|                                            |
|o16 : Complex                               |
+--------------------------------------------+
|i17 : betti C2                              |
|                                            |
|             0 1 2 3                        |
|o17 = total: 1 3 3 1                        |
|          0: 1 1 . .                        |
|          1: . 1 1 .                        |
|          2: . 1 1 .                        |
|          3: . . 1 1                        |
|                                            |
|o17 : BettiTally                            |
+--------------------------------------------+
|i18 : betti(C2, Weights => {1})             |
|                                            |
|             0 1 2 3                        |
|o18 = total: 1 3 3 1                        |
|         -9: . . . 1                        |
|         -8: . . . .                        |
|         -7: . . 1 .                        |
|         -6: . . 1 .                        |
|         -5: . . 1 .                        |
|         -4: . 1 . .                        |
|         -3: . 1 . .                        |
|         -2: . 1 . .                        |
|         -1: . . . .                        |
|          0: 1 . . .                        |
|                                            |
|o18 : BettiTally                            |
+--------------------------------------------+

The following example is the Cox ring of the second Hirzebruch surface, and the
complex is the free resolution of the irrelevant ideal.

+----------------------------------------------------------+
|i19 : T = QQ[a,b,c,d,Degrees=>{{1,0},{-2,1},{1,0},{0,1}}];|
+----------------------------------------------------------+
|i20 : B = intersect(ideal(a,c),ideal(b,d))                |
|                                                          |
|o20 = ideal (b*c, a*b, c*d, a*d)                          |
|                                                          |
|o20 : Ideal of T                                          |
+----------------------------------------------------------+
|i21 : C3 = freeResolution B                               |
|                                                          |
|       1      4      4      1                             |
|o21 = T  <-- T  <-- T  <-- T                              |
|                                                          |
|      0      1      2      3                              |
|                                                          |
|o21 : Complex                                             |
+----------------------------------------------------------+
|i22 : dd^C3                                               |
|                                                          |
|           1                       4                      |
|o22 = 0 : T  <------------------- T  : 1                  |
|                | ab bc ad cd |                           |
|                                                          |
|           4                               4              |
|      1 : T  <--------------------------- T  : 2          |
|                {-1, 1} | -c -d 0  0  |                   |
|                {-1, 1} | a  0  0  -d |                   |
|                {1, 1}  | 0  b  -c 0  |                   |
|                {1, 1}  | 0  0  a  b  |                   |
|                                                          |
|           4                      1                       |
|      2 : T  <------------------ T  : 3                   |
|                {0, 1}  | d  |                            |
|                {-1, 2} | -c |                            |
|                {2, 1}  | -b |                            |
|                {-1, 2} | a  |                            |
|                                                          |
|o22 : ComplexMap                                          |
+----------------------------------------------------------+
|i23 : heft T                                              |
|                                                          |
|o23 = {1, 3}                                              |
|                                                          |
|o23 : List                                                |
+----------------------------------------------------------+
|i24 : betti C3                                            |
|                                                          |
|             0 1 2 3                                      |
|o24 = total: 1 4 4 1                                      |
|          0: 1 . . .                                      |
|          1: . 2 1 .                                      |
|          2: . . . .                                      |
|          3: . 2 3 1                                      |
|                                                          |
|o24 : BettiTally                                          |
+----------------------------------------------------------+
|i25 : betti(C3, Weights => {1,0})                         |
|                                                          |
|             0 1 2 3                                      |
|o25 = total: 1 4 4 1                                      |
|         -3: . . 2 1                                      |
|         -2: . 2 1 .                                      |
|         -1: . . . .                                      |
|          0: 1 2 1 .                                      |
|                                                          |
|o25 : BettiTally                                          |
+----------------------------------------------------------+
|i26 : betti(C3, Weights => {0,1})                         |
|                                                          |
|             0 1 2 3                                      |
|o26 = total: 1 4 4 1                                      |
|         -1: . . 2 1                                      |
|          0: 1 4 2 .                                      |
|                                                          |
|o26 : BettiTally                                          |
+----------------------------------------------------------+
|i27 : degrees C3_1                                        |
|                                                          |
|o27 = {{-1, 1}, {-1, 1}, {1, 1}, {1, 1}}                  |
|                                                          |
|o27 : List                                                |
+----------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * betti (Macaulay2Doc) -- display or modify a Betti diagram
  * BettiTally (Macaulay2Doc) -- the class of all Betti
    tallies

Ways to use this method:
========================

  * betti(Complex) -- display of degrees in a
    complex

canonicalMap -- gets the natural map arising from various constructions
***********************************************************************

Synopsis
========

  * Usage:
        g = canonicalMap(D, C)
  * Inputs:
      * C, a complex,
      * D, a complex,
  * Optional inputs (Macaulay2Doc),:
      * UseTarget => a Boolean value (Macaulay2Doc), default
        value null, determines the choice of canonical map when $D$ is a
        cylinder of a map $f$ and the source and target of $f$ are the same
  * Outputs:
      * g, a map of complexes,

Description
===========

A canonical map, also called a natural map, is a map that arises naturally from
the definition or the construction of the object.

The following six constructions are supported: kernel, cokernel, image,
coimage, cone, and cylinder.

The kernel of a complex map, comes with a natural
injection into the source complex. This natural map is always a complex
morphism.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c,d];                                                    |
+-----------------------------------------------------------------------------+
|i2 : D = freeResolution coker vars R                                         |
|                                                                             |
|      1      4      6      4      1                                          |
|o2 = R  <-- R  <-- R  <-- R  <-- R                                           |
|                                                                             |
|     0      1      2      3      4                                           |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : C = (freeResolution coker matrix"a,b,c")[1]                             |
|                                                                             |
|      1      3      3      1                                                 |
|o3 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     -1     0      1      2                                                  |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : f = randomComplexMap(D, C, Cycle=>true)                                 |
|                                                                             |
|                    1                                                        |
|o4 = -1 : 0 <----- R  : -1                                                   |
|               0                                                             |
|                                                                             |
|          1                                                           3      |
|     0 : R  <------------------------------------------------------- R  : 0  |
|               | -46a+17b-8c+26d -38a-2b+23c-10d -30a-18b-9c+37d |           |
|                                                                             |
|          4                                                               3  |
|     1 : R  <----------------------------------------------------------- R  :|
|               {1} | 38a+3b-10c+25d  30a+36b+14c-9d -47b-19c+2d      |       |
|               {1} | -47a+17b-29c-8d -18a+39c-22d   -24a+18b-32c-27d |       |
|               {1} | -13a+21b-34d    50a-22b-8c+24d -19a+39b+23c-18d |       |
|               {1} | -15a+34b+34c    -28a+22b+2c    -2a-10b+8c       |       |
|                                                                             |
|          6                               1                                  |
|     2 : R  <--------------------------- R  : 2                              |
|               {2} | 24a-36b-30c-29d |                                       |
|               {2} | 19a+19b-10c-29d |                                       |
|               {2} | -8a-22b-29c-24d |                                       |
|               {2} | 2a+38b-47c      |                                       |
|               {2} | 45a+22b+16c     |                                       |
|               {2} | -47a-48b-34c    |                                       |
|                                                                             |
|o4 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|1                                                                            |
+-----------------------------------------------------------------------------+
|i5 : assert isComplexMorphism f                                              |
+-----------------------------------------------------------------------------+
|i6 : K1 = kernel f                                                           |
|                                                                             |
|      1                                                                      |
|o6 = R  <-- image {1} | -14a-22b-50c-9d -32b+17c-42d -27a-21b+50c+27d | <--  |
|                  {1} | a+15b-13c+17d   22b+40c+33d  -27b+6c+10d      |      |
|     -1           {1} | 0               b+31c-38d    a+27c-19d        |      |
|                                                                             |
|            0                                                                |
|                                                                             |
|o6 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|image 0 <-- image 0                                                          |
|                                                                             |
|1           2                                                                |
+-----------------------------------------------------------------------------+
|i7 : g = canonicalMap(source f, K1)                                          |
|                                                                             |
|           1             1                                                   |
|o7 = -1 : R  <--------- R  : -1                                              |
|                | 1 |                                                        |
|                                                                             |
|          3                                                                  |
|     0 : R  <--------------------------------------------------------- image |
|               {1} | -14a-22b-50c-9d -32b+17c-42d -27a-21b+50c+27d |         |
|               {1} | a+15b-13c+17d   22b+40c+33d  -27b+6c+10d      |         |
|               {1} | 0               b+31c-38d    a+27c-19d        |         |
|                                                                             |
|          3                                                                  |
|     1 : R  <----- image 0 : 1                                               |
|               0                                                             |
|                                                                             |
|          1                                                                  |
|     2 : R  <----- image 0 : 2                                               |
|               0                                                             |
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|{1} | -14a-22b-50c-9d -32b+17c-42d -27a-21b+50c+27d | : 0                    |
|{1} | a+15b-13c+17d   22b+40c+33d  -27b+6c+10d      |                        |
|{1} | 0               b+31c-38d    a+27c-19d        |                        |
+-----------------------------------------------------------------------------+
|i8 : degree g                                                                |
|                                                                             |
|o8 = 0                                                                       |
+-----------------------------------------------------------------------------+
|i9 : assert(isWellDefined g and isComplexMorphism g)                         |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i10 : f2 = randomComplexMap(D, C)                                            |
|                                                                             |
|                     1                                                       |
|o10 = -1 : 0 <----- R  : -1                                                  |
|                0                                                            |
|                                                                             |
|           1                                                           3     |
|      0 : R  <------------------------------------------------------- R  : 0 |
|                | 47a+19b-16c+7d 15a-23b+39c+43d -17a-11b+48c+36d |          |
|                                                                             |
|           4                                                                3|
|      1 : R  <------------------------------------------------------------ R |
|                {1} | 35a+11b-38c+33d -47a+15b-37c-13d -48a-15b+39c    |     |
|                {1} | 40a+11b+46c-28d -10a+30b-18c+39d 33a-49b-33c-19d |     |
|                {1} | a-3b+22c-47d    27a-22b+32c-9d   17a-20b+44c-39d |     |
|                {1} | -23a-7b+2c+29d  -32a-20b+24c-30d 36a+9b-39c+4d   |     |
|                                                                             |
|           6                               1                                 |
|      2 : R  <--------------------------- R  : 2                             |
|                {2} | 13a-26b+22c-49d |                                      |
|                {2} | -11a-8b+43c-8d  |                                      |
|                {2} | 36a-3b-22c-30d  |                                      |
|                {2} | 41a+16b-28c-6d  |                                      |
|                {2} | 35a-9b-35c+6d   |                                      |
|                {2} | 40a+3b-31c+25d  |                                      |
|                                                                             |
|o10 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|: 1                                                                          |
+-----------------------------------------------------------------------------+
|i11 : assert not isComplexMorphism f2                                        |
+-----------------------------------------------------------------------------+
|i12 : K2 = kernel f2                                                         |
|                                                                             |
|       1                                                                     |
|o12 = R  <-- image {1} | -39a-21b+40c-31d -20b-28c+37d 24a+47b+6c+38d | <--  |
|                   {1} | a+9b+19c-2d      -17b+26c-23d -49b-32c+5d    |      |
|      -1           {1} | 0                b-c-19d      a+28c-33d      |      |
|                                                                             |
|             0                                                               |
|                                                                             |
|o12 : Complex                                                                |
|-----------------------------------------------------------------------------|
|image 0 <-- image 0                                                          |
|                                                                             |
|1           2                                                                |
+-----------------------------------------------------------------------------+
|i13 : g2 = canonicalMap(source f2, K2)                                       |
|                                                                             |
|            1             1                                                  |
|o13 = -1 : R  <--------- R  : -1                                             |
|                 | 1 |                                                       |
|                                                                             |
|           3                                                                 |
|      0 : R  <-------------------------------------------------------- image |
|                {1} | -39a-21b+40c-31d -20b-28c+37d 24a+47b+6c+38d |         |
|                {1} | a+9b+19c-2d      -17b+26c-23d -49b-32c+5d    |         |
|                {1} | 0                b-c-19d      a+28c-33d      |         |
|                                                                             |
|           3                                                                 |
|      1 : R  <----- image 0 : 1                                              |
|                0                                                            |
|                                                                             |
|           1                                                                 |
|      2 : R  <----- image 0 : 2                                              |
|                0                                                            |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|{1} | -39a-21b+40c-31d -20b-28c+37d 24a+47b+6c+38d | : 0                     |
|{1} | a+9b+19c-2d      -17b+26c-23d -49b-32c+5d    |                         |
|{1} | 0                b-c-19d      a+28c-33d      |                         |
+-----------------------------------------------------------------------------+
|i14 : assert(isWellDefined g2 and isComplexMorphism g2)                      |
+-----------------------------------------------------------------------------+

The cokernel of a complex map, comes with a
natural surjection from the target complex.

+-----------------------------------------------------------------------------+
|i15 : Q = cokernel f                                                         |
|                                                                             |
|                                                                             |
|o15 = cokernel | -46a+17b-8c+26d -38a-2b+23c-10d -30a-18b-9c+37d | <--       |
|                                                                             |
|      0                                                                      |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o15 : Complex                                                                |
|-----------------------------------------------------------------------------|
|                                                                             |
|cokernel {1} | 38a+3b-10c+25d  30a+36b+14c-9d -47b-19c+2d      | <-- cokernel|
|         {1} | -47a+17b-29c-8d -18a+39c-22d   -24a+18b-32c-27d |             |
|         {1} | -13a+21b-34d    50a-22b-8c+24d -19a+39b+23c-18d |             |
|         {1} | -15a+34b+34c    -28a+22b+2c    -2a-10b+8c       |             |
|                                                                             |
|1                                                                            |
|                                                                             |
|                                                                     2       |
|-----------------------------------------------------------------------------|
|                             4      1                                        |
|{2} | 24a-36b-30c-29d | <-- R  <-- R                                         |
|{2} | 19a+19b-10c-29d |                                                      |
|{2} | -8a-22b-29c-24d |     3      4                                         |
|{2} | 2a+38b-47c      |                                                      |
|{2} | 45a+22b+16c     |                                                      |
|{2} | -47a-48b-34c    |                                                      |
+-----------------------------------------------------------------------------+
|i16 : g3 = canonicalMap(Q, target f)                                         |
|                                                                             |
|                                                                             |
|o16 = 0 : cokernel | -46a+17b-8c+26d -38a-2b+23c-10d -30a-18b-9c+37d         |
|                                                                             |
|                                                                             |
|                                                                             |
|      1 : cokernel {1} | 38a+3b-10c+25d  30a+36b+14c-9d -47b-19c+2d          |
|                   {1} | -47a+17b-29c-8d -18a+39c-22d   -24a+18b-32c-        |
|                   {1} | -13a+21b-34d    50a-22b-8c+24d -19a+39b+23c-        |
|                   {1} | -15a+34b+34c    -28a+22b+2c    -2a-10b+8c           |
|                                                                             |
|                                                                             |
|                                                                             |
|      2 : cokernel {2} | 24a-36b-30c-29d | <----------------------- R        |
|                   {2} | 19a+19b-10c-29d |    {2} | 1 0 0 0 0 0 |            |
|                   {2} | -8a-22b-29c-24d |    {2} | 0 1 0 0 0 0 |            |
|                   {2} | 2a+38b-47c      |    {2} | 0 0 1 0 0 0 |            |
|                   {2} | 45a+22b+16c     |    {2} | 0 0 0 1 0 0 |            |
|                   {2} | -47a-48b-34c    |    {2} | 0 0 0 0 1 0 |            |
|                                              {2} | 0 0 0 0 0 1 |            |
|                                                                             |
|           4                       4                                         |
|      3 : R  <------------------- R  : 3                                     |
|                {3} | 1 0 0 0 |                                              |
|                {3} | 0 1 0 0 |                                              |
|                {3} | 0 0 1 0 |                                              |
|                {3} | 0 0 0 1 |                                              |
|                                                                             |
|           1                 1                                               |
|      4 : R  <------------- R  : 4                                           |
|                {4} | 1 |                                                    |
|                                                                             |
|o16 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|              1                                                              |
|| <--------- R  : 0                                                          |
|     | 1 |                                                                   |
|                                                                             |
|                            4                                                |
|    | <------------------- R  : 1                                            |
|27d |    {1} | 1 0 0 0 |                                                     |
|18d |    {1} | 0 1 0 0 |                                                     |
|    |    {1} | 0 0 1 0 |                                                     |
|         {1} | 0 0 0 1 |                                                     |
|                                                                             |
|6                                                                            |
|  : 2                                                                        |
+-----------------------------------------------------------------------------+
|i17 : assert(isWellDefined g3 and isComplexMorphism g3)                      |
+-----------------------------------------------------------------------------+

The image of a complex map, comes with a natural
injection into the target complex.

+-----------------------------------------------------------------------------+
|i18 : I = image f                                                            |
|                                                                             |
|o18 = image | -46a+17b-8c+26d -38a-2b+23c-10d -30a-18b-9c+37d | <-- image {1}|
|                                                                          {1}|
|      0                                                                   {1}|
|                                                                          {1}|
|                                                                             |
|                                                                    1        |
|                                                                             |
|                                                                             |
|                                                                             |
|o18 : Complex                                                                |
|-----------------------------------------------------------------------------|
|| 38a+3b-10c+25d  30a+36b+14c-9d -47b-19c+2d      | <-- image {2} |          |
|| -47a+17b-29c-8d -18a+39c-22d   -24a+18b-32c-27d |           {2} |          |
|| -13a+21b-34d    50a-22b-8c+24d -19a+39b+23c-18d |           {2} |          |
|| -15a+34b+34c    -28a+22b+2c    -2a-10b+8c       |           {2} |          |
|                                                              {2} |          |
|                                                              {2} |          |
|                                                                             |
|                                                        2                    |
|-----------------------------------------------------------------------------|
|24a-36b-30c-29d | <-- image 0 <-- image 0                                    |
|19a+19b-10c-29d |                                                            |
|-8a-22b-29c-24d |     3           4                                          |
|2a+38b-47c      |                                                            |
|45a+22b+16c     |                                                            |
|-47a-48b-34c    |                                                            |
+-----------------------------------------------------------------------------+
|i19 : g4 = canonicalMap(target f, I)                                         |
|                                                                             |
|           1                                                                 |
|o19 = 0 : R  <------------------------------------------------------- image ||
|                | -46a+17b-8c+26d -38a-2b+23c-10d -30a-18b-9c+37d |          |
|                                                                             |
|           4                                                                 |
|      1 : R  <----------------------------------------------------------- ima|
|                {1} | 38a+3b-10c+25d  30a+36b+14c-9d -47b-19c+2d      |      |
|                {1} | -47a+17b-29c-8d -18a+39c-22d   -24a+18b-32c-27d |      |
|                {1} | -13a+21b-34d    50a-22b-8c+24d -19a+39b+23c-18d |      |
|                {1} | -15a+34b+34c    -28a+22b+2c    -2a-10b+8c       |      |
|                                                                             |
|           6                                                                 |
|      2 : R  <--------------------------- image {2} | 24a-36b-30c-29d | : 2  |
|                {2} | 24a-36b-30c-29d |         {2} | 19a+19b-10c-29d |      |
|                {2} | 19a+19b-10c-29d |         {2} | -8a-22b-29c-24d |      |
|                {2} | -8a-22b-29c-24d |         {2} | 2a+38b-47c      |      |
|                {2} | 2a+38b-47c      |         {2} | 45a+22b+16c     |      |
|                {2} | 45a+22b+16c     |         {2} | -47a-48b-34c    |      |
|                {2} | -47a-48b-34c    |                                      |
|                                                                             |
|           4                                                                 |
|      3 : R  <----- image 0 : 3                                              |
|                0                                                            |
|                                                                             |
|           1                                                                 |
|      4 : R  <----- image 0 : 4                                              |
|                0                                                            |
|                                                                             |
|o19 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
| -46a+17b-8c+26d -38a-2b+23c-10d -30a-18b-9c+37d | : 0                       |
|                                                                             |
|                                                                             |
|                                                                             |
|ge {1} | 38a+3b-10c+25d  30a+36b+14c-9d -47b-19c+2d      | : 1               |
|   {1} | -47a+17b-29c-8d -18a+39c-22d   -24a+18b-32c-27d |                   |
|   {1} | -13a+21b-34d    50a-22b-8c+24d -19a+39b+23c-18d |                   |
|   {1} | -15a+34b+34c    -28a+22b+2c    -2a-10b+8c       |                   |
+-----------------------------------------------------------------------------+
|i20 : assert(isWellDefined g4 and isComplexMorphism g4)                      |
+-----------------------------------------------------------------------------+

The coimage of a complex map, comes with a
natural surjection from the source complex. This natural map is always a
complex morphism.

+-----------------------------------------------------------------------------+
|i21 : J = coimage f                                                          |
|                                                                             |
|                                                                             |
|o21 = cokernel | 1 | <-- cokernel {1} | -14a-22b-50c-9d -32b+17c-42d         |
|                                  {1} | a+15b-13c+17d   22b+40c+33d          |
|      -1                          {1} | 0               b+31c-38d            |
|                                                                             |
|                         0                                                   |
|                                                                             |
|o21 : Complex                                                                |
|-----------------------------------------------------------------------------|
|                        3      1                                             |
|-27a-21b+50c+27d | <-- R  <-- R                                              |
|-27b+6c+10d      |                                                           |
|a+27c-19d        |     1      2                                              |
+-----------------------------------------------------------------------------+
|i22 : g5 = canonicalMap(J, source f)                                         |
|                                                                             |
|                                  1                                          |
|o22 = -1 : cokernel | 1 | <----- R  : -1                                     |
|                             0                                               |
|                                                                             |
|                                                                             |
|      0 : cokernel {1} | -14a-22b-50c-9d -32b+17c-42d -27a-21b+50c+27d |     |
|                   {1} | a+15b-13c+17d   22b+40c+33d  -27b+6c+10d      |     |
|                   {1} | 0               b+31c-38d    a+27c-19d        |     |
|                                                                             |
|                                                                             |
|           3                     3                                           |
|      1 : R  <----------------- R  : 1                                       |
|                {2} | 1 0 0 |                                                |
|                {2} | 0 1 0 |                                                |
|                {2} | 0 0 1 |                                                |
|                                                                             |
|           1                 1                                               |
|      2 : R  <------------- R  : 2                                           |
|                {3} | 1 |                                                    |
|                                                                             |
|o22 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                    3                                                        |
|<----------------- R  : 0                                                    |
|   {1} | 1 0 0 |                                                             |
|   {1} | 0 1 0 |                                                             |
|   {1} | 0 0 1 |                                                             |
+-----------------------------------------------------------------------------+
|i23 : assert(isWellDefined g5 and isComplexMorphism g5)                      |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i24 : J2 = coimage f2                                                        |
|                                                                             |
|                                                                             |
|o24 = cokernel | 1 | <-- cokernel {1} | -39a-21b+40c-31d -20b-28c+37d        |
|                                  {1} | a+9b+19c-2d      -17b+26c-23d        |
|      -1                          {1} | 0                b-c-19d             |
|                                                                             |
|                         0                                                   |
|                                                                             |
|o24 : Complex                                                                |
|-----------------------------------------------------------------------------|
|                      3      1                                               |
|24a+47b+6c+38d | <-- R  <-- R                                                |
|-49b-32c+5d    |                                                             |
|a+28c-33d      |     1      2                                                |
+-----------------------------------------------------------------------------+
|i25 : g6 = canonicalMap(J2, source f2)                                       |
|                                                                             |
|                                  1                                          |
|o25 = -1 : cokernel | 1 | <----- R  : -1                                     |
|                             0                                               |
|                                                                             |
|                                                                             |
|      0 : cokernel {1} | -39a-21b+40c-31d -20b-28c+37d 24a+47b+6c+38d |      |
|                   {1} | a+9b+19c-2d      -17b+26c-23d -49b-32c+5d    |      |
|                   {1} | 0                b-c-19d      a+28c-33d      |      |
|                                                                             |
|                                                                             |
|           3                     3                                           |
|      1 : R  <----------------- R  : 1                                       |
|                {2} | 1 0 0 |                                                |
|                {2} | 0 1 0 |                                                |
|                {2} | 0 0 1 |                                                |
|                                                                             |
|           1                 1                                               |
|      2 : R  <------------- R  : 2                                           |
|                {3} | 1 |                                                    |
|                                                                             |
|o25 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                    3                                                        |
|<----------------- R  : 0                                                    |
|   {1} | 1 0 0 |                                                             |
|   {1} | 0 1 0 |                                                             |
|   {1} | 0 0 1 |                                                             |
+-----------------------------------------------------------------------------+
|i26 : assert(isWellDefined g6 and isComplexMorphism g6)                      |
+-----------------------------------------------------------------------------+

The cone of a complex morphism, comes with two
natural maps.  Given a map $f : C \to D$, let $E$ denote the cone of $f$.  The
first is a natural injection from the target $D$ of $f$ into $E$.  The second
is a natural surjection from $E$ to $C[-1]$. Together, these maps form a short
exact sequence of complexes.

+---------------------------------------------------------+
|i27 : E = cone f                                         |
|                                                         |
|       2      7      9      5      1                     |
|o27 = R  <-- R  <-- R  <-- R  <-- R                      |
|                                                         |
|      0      1      2      3      4                      |
|                                                         |
|o27 : Complex                                            |
+---------------------------------------------------------+
|i28 : g = canonicalMap(E, target f)                      |
|                                                         |
|           2             1                               |
|o28 = 0 : R  <--------- R  : 0                           |
|                | 0 |                                    |
|                | 1 |                                    |
|                                                         |
|           7                       4                     |
|      1 : R  <------------------- R  : 1                 |
|                {1} | 0 0 0 0 |                          |
|                {1} | 0 0 0 0 |                          |
|                {1} | 0 0 0 0 |                          |
|                {1} | 1 0 0 0 |                          |
|                {1} | 0 1 0 0 |                          |
|                {1} | 0 0 1 0 |                          |
|                {1} | 0 0 0 1 |                          |
|                                                         |
|           9                           6                 |
|      2 : R  <----------------------- R  : 2             |
|                {2} | 0 0 0 0 0 0 |                      |
|                {2} | 0 0 0 0 0 0 |                      |
|                {2} | 0 0 0 0 0 0 |                      |
|                {2} | 1 0 0 0 0 0 |                      |
|                {2} | 0 1 0 0 0 0 |                      |
|                {2} | 0 0 1 0 0 0 |                      |
|                {2} | 0 0 0 1 0 0 |                      |
|                {2} | 0 0 0 0 1 0 |                      |
|                {2} | 0 0 0 0 0 1 |                      |
|                                                         |
|           5                       4                     |
|      3 : R  <------------------- R  : 3                 |
|                {3} | 0 0 0 0 |                          |
|                {3} | 1 0 0 0 |                          |
|                {3} | 0 1 0 0 |                          |
|                {3} | 0 0 1 0 |                          |
|                {3} | 0 0 0 1 |                          |
|                                                         |
|           1                 1                           |
|      4 : R  <------------- R  : 4                       |
|                {4} | 1 |                                |
|                                                         |
|o28 : ComplexMap                                         |
+---------------------------------------------------------+
|i29 : h = canonicalMap((source f)[-1], E)                |
|                                                         |
|           1               2                             |
|o29 = 0 : R  <----------- R  : 0                         |
|                | 1 0 |                                  |
|                                                         |
|           3                             7               |
|      1 : R  <------------------------- R  : 1           |
|                {1} | 1 0 0 0 0 0 0 |                    |
|                {1} | 0 1 0 0 0 0 0 |                    |
|                {1} | 0 0 1 0 0 0 0 |                    |
|                                                         |
|           3                                 9           |
|      2 : R  <----------------------------- R  : 2       |
|                {2} | 1 0 0 0 0 0 0 0 0 |                |
|                {2} | 0 1 0 0 0 0 0 0 0 |                |
|                {2} | 0 0 1 0 0 0 0 0 0 |                |
|                                                         |
|           1                         5                   |
|      3 : R  <--------------------- R  : 3               |
|                {3} | 1 0 0 0 0 |                        |
|                                                         |
|o29 : ComplexMap                                         |
+---------------------------------------------------------+
|i30 : assert(isWellDefined g and isWellDefined h)        |
+---------------------------------------------------------+
|i31 : assert(isComplexMorphism g and isComplexMorphism h)|
+---------------------------------------------------------+
|i32 : assert isShortExactSequence(h,g)                   |
+---------------------------------------------------------+

The cylinder of a complex map, comes with four natural maps.
Given a map $f : C \to D$, let $F$ denote the cylinder of $f$.  The first is
the natural injection from the source $C$ of $f$ into the cylinder $F$.
Together these two maps form a short exact sequence of complexes.

+---------------------------------------------------------+
|i33 : F = cylinder f                                     |
|                                                         |
|       1      5      10      10      5      1            |
|o33 = R  <-- R  <-- R   <-- R   <-- R  <-- R             |
|                                                         |
|      -1     0      1       2       3      4             |
|                                                         |
|o33 : Complex                                            |
+---------------------------------------------------------+
|i34 : g = canonicalMap(F, source f)                      |
|                                                         |
|            1             1                              |
|o34 = -1 : R  <--------- R  : -1                         |
|                 | 1 |                                   |
|                                                         |
|           5                     3                       |
|      0 : R  <----------------- R  : 0                   |
|                {0} | 0 0 0 |                            |
|                {1} | 1 0 0 |                            |
|                {1} | 0 1 0 |                            |
|                {1} | 0 0 1 |                            |
|                {0} | 0 0 0 |                            |
|                                                         |
|           10                     3                      |
|      1 : R   <----------------- R  : 1                  |
|                 {1} | 0 0 0 |                           |
|                 {1} | 0 0 0 |                           |
|                 {1} | 0 0 0 |                           |
|                 {2} | 1 0 0 |                           |
|                 {2} | 0 1 0 |                           |
|                 {2} | 0 0 1 |                           |
|                 {1} | 0 0 0 |                           |
|                 {1} | 0 0 0 |                           |
|                 {1} | 0 0 0 |                           |
|                 {1} | 0 0 0 |                           |
|                                                         |
|           10                 1                          |
|      2 : R   <------------- R  : 2                      |
|                 {2} | 0 |                               |
|                 {2} | 0 |                               |
|                 {2} | 0 |                               |
|                 {3} | 1 |                               |
|                 {2} | 0 |                               |
|                 {2} | 0 |                               |
|                 {2} | 0 |                               |
|                 {2} | 0 |                               |
|                 {2} | 0 |                               |
|                 {2} | 0 |                               |
|                                                         |
|o34 : ComplexMap                                         |
+---------------------------------------------------------+
|i35 : h = canonicalMap(E, F)                             |
|                                                         |
|           2                     5                       |
|o35 = 0 : R  <----------------- R  : 0                   |
|                | 1 0 0 0 0 |                            |
|                | 0 0 0 0 1 |                            |
|                                                         |
|           7                                   10        |
|      1 : R  <------------------------------- R   : 1    |
|                {1} | 1 0 0 0 0 0 0 0 0 0 |              |
|                {1} | 0 1 0 0 0 0 0 0 0 0 |              |
|                {1} | 0 0 1 0 0 0 0 0 0 0 |              |
|                {1} | 0 0 0 0 0 0 1 0 0 0 |              |
|                {1} | 0 0 0 0 0 0 0 1 0 0 |              |
|                {1} | 0 0 0 0 0 0 0 0 1 0 |              |
|                {1} | 0 0 0 0 0 0 0 0 0 1 |              |
|                                                         |
|           9                                   10        |
|      2 : R  <------------------------------- R   : 2    |
|                {2} | 1 0 0 0 0 0 0 0 0 0 |              |
|                {2} | 0 1 0 0 0 0 0 0 0 0 |              |
|                {2} | 0 0 1 0 0 0 0 0 0 0 |              |
|                {2} | 0 0 0 0 1 0 0 0 0 0 |              |
|                {2} | 0 0 0 0 0 1 0 0 0 0 |              |
|                {2} | 0 0 0 0 0 0 1 0 0 0 |              |
|                {2} | 0 0 0 0 0 0 0 1 0 0 |              |
|                {2} | 0 0 0 0 0 0 0 0 1 0 |              |
|                {2} | 0 0 0 0 0 0 0 0 0 1 |              |
|                                                         |
|           5                         5                   |
|      3 : R  <--------------------- R  : 3               |
|                {3} | 1 0 0 0 0 |                        |
|                {3} | 0 1 0 0 0 |                        |
|                {3} | 0 0 1 0 0 |                        |
|                {3} | 0 0 0 1 0 |                        |
|                {3} | 0 0 0 0 1 |                        |
|                                                         |
|           1                 1                           |
|      4 : R  <------------- R  : 4                       |
|                {4} | 1 |                                |
|                                                         |
|o35 : ComplexMap                                         |
+---------------------------------------------------------+
|i36 : assert(isWellDefined g and isWellDefined h)        |
+---------------------------------------------------------+
|i37 : assert(isComplexMorphism g and isComplexMorphism h)|
+---------------------------------------------------------+
|i38 : assert isShortExactSequence(h,g)                   |
+---------------------------------------------------------+

The third is the natural injection from the target $D$ of $F$ into the cylinder
$F$. The fourth is the natural surjection from the cylinder $F$ to the target
$D$ of $f$. However, these two maps do not form a short exact sequence of
complexes.

+-----------------------------------------------------------------------------+
|i39 : g' = canonicalMap(F, target f)                                         |
|                                                                             |
|           5                 1                                               |
|o39 = 0 : R  <------------- R  : 0                                           |
|                {0} | 0 |                                                    |
|                {1} | 0 |                                                    |
|                {1} | 0 |                                                    |
|                {1} | 0 |                                                    |
|                {0} | 1 |                                                    |
|                                                                             |
|           10                       4                                        |
|      1 : R   <------------------- R  : 1                                    |
|                 {1} | 0 0 0 0 |                                             |
|                 {1} | 0 0 0 0 |                                             |
|                 {1} | 0 0 0 0 |                                             |
|                 {2} | 0 0 0 0 |                                             |
|                 {2} | 0 0 0 0 |                                             |
|                 {2} | 0 0 0 0 |                                             |
|                 {1} | 1 0 0 0 |                                             |
|                 {1} | 0 1 0 0 |                                             |
|                 {1} | 0 0 1 0 |                                             |
|                 {1} | 0 0 0 1 |                                             |
|                                                                             |
|           10                           6                                    |
|      2 : R   <----------------------- R  : 2                                |
|                 {2} | 0 0 0 0 0 0 |                                         |
|                 {2} | 0 0 0 0 0 0 |                                         |
|                 {2} | 0 0 0 0 0 0 |                                         |
|                 {3} | 0 0 0 0 0 0 |                                         |
|                 {2} | 1 0 0 0 0 0 |                                         |
|                 {2} | 0 1 0 0 0 0 |                                         |
|                 {2} | 0 0 1 0 0 0 |                                         |
|                 {2} | 0 0 0 1 0 0 |                                         |
|                 {2} | 0 0 0 0 1 0 |                                         |
|                 {2} | 0 0 0 0 0 1 |                                         |
|                                                                             |
|           5                       4                                         |
|      3 : R  <------------------- R  : 3                                     |
|                {3} | 0 0 0 0 |                                              |
|                {3} | 1 0 0 0 |                                              |
|                {3} | 0 1 0 0 |                                              |
|                {3} | 0 0 1 0 |                                              |
|                {3} | 0 0 0 1 |                                              |
|                                                                             |
|           1                 1                                               |
|      4 : R  <------------- R  : 4                                           |
|                {4} | 1 |                                                    |
|                                                                             |
|o39 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i40 : h' = canonicalMap(target f, F)                                         |
|                                                                             |
|           1                                                               5 |
|o40 = 0 : R  <----------------------------------------------------------- R  |
|                | 0 -46a+17b-8c+26d -38a-2b+23c-10d -30a-18b-9c+37d 1 |      |
|                                                                             |
|           4                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {1} | 0 0 0 38a+3b-10c+25d  30a+36b+14c-9d -47b-19c+2d      1|
|                {1} | 0 0 0 -47a+17b-29c-8d -18a+39c-22d   -24a+18b-32c-27d 0|
|                {1} | 0 0 0 -13a+21b-34d    50a-22b-8c+24d -19a+39b+23c-18d 0|
|                {1} | 0 0 0 -15a+34b+34c    -28a+22b+2c    -2a-10b+8c       0|
|                                                                             |
|           6                                                 10              |
|      2 : R  <--------------------------------------------- R   : 2          |
|                {2} | 0 0 0 24a-36b-30c-29d 1 0 0 0 0 0 |                    |
|                {2} | 0 0 0 19a+19b-10c-29d 0 1 0 0 0 0 |                    |
|                {2} | 0 0 0 -8a-22b-29c-24d 0 0 1 0 0 0 |                    |
|                {2} | 0 0 0 2a+38b-47c      0 0 0 1 0 0 |                    |
|                {2} | 0 0 0 45a+22b+16c     0 0 0 0 1 0 |                    |
|                {2} | 0 0 0 -47a-48b-34c    0 0 0 0 0 1 |                    |
|                                                                             |
|           4                         5                                       |
|      3 : R  <--------------------- R  : 3                                   |
|                {3} | 0 1 0 0 0 |                                            |
|                {3} | 0 0 1 0 0 |                                            |
|                {3} | 0 0 0 1 0 |                                            |
|                {3} | 0 0 0 0 1 |                                            |
|                                                                             |
|           1                 1                                               |
|      4 : R  <------------- R  : 4                                           |
|                {4} | 1 |                                                    |
|                                                                             |
|o40 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|: 0                                                                          |
|                                                                             |
|                                                                             |
|            10                                                               |
|---------- R   : 1                                                           |
| 0 0 0 |                                                                     |
| 1 0 0 |                                                                     |
| 0 1 0 |                                                                     |
| 0 0 1 |                                                                     |
+-----------------------------------------------------------------------------+
|i41 : assert(isWellDefined g' and isWellDefined h')                          |
+-----------------------------------------------------------------------------+
|i42 : assert(isComplexMorphism g' and isComplexMorphism h')                  |
+-----------------------------------------------------------------------------+
|i43 : assert not isShortExactSequence(h',g')                                 |
+-----------------------------------------------------------------------------+

When $D == C$, the optional argument UseTarget selects the appropriate natural
map.

+---------------------------------------------------------+
|i44 : f' = id_C                                          |
|                                                         |
|            1             1                              |
|o44 = -1 : R  <--------- R  : -1                         |
|                 | 1 |                                   |
|                                                         |
|           3                     3                       |
|      0 : R  <----------------- R  : 0                   |
|                {1} | 1 0 0 |                            |
|                {1} | 0 1 0 |                            |
|                {1} | 0 0 1 |                            |
|                                                         |
|           3                     3                       |
|      1 : R  <----------------- R  : 1                   |
|                {2} | 1 0 0 |                            |
|                {2} | 0 1 0 |                            |
|                {2} | 0 0 1 |                            |
|                                                         |
|           1                 1                           |
|      2 : R  <------------- R  : 2                       |
|                {3} | 1 |                                |
|                                                         |
|o44 : ComplexMap                                         |
+---------------------------------------------------------+
|i45 : F' = cylinder f'                                   |
|                                                         |
|       2      7      9      5      1                     |
|o45 = R  <-- R  <-- R  <-- R  <-- R                      |
|                                                         |
|      -1     0      1      2      3                      |
|                                                         |
|o45 : Complex                                            |
+---------------------------------------------------------+
|i46 : g = canonicalMap(F', C, UseTarget=>true)           |
|                                                         |
|            2             1                              |
|o46 = -1 : R  <--------- R  : -1                         |
|                 | 0 |                                   |
|                 | 1 |                                   |
|                                                         |
|           7                     3                       |
|      0 : R  <----------------- R  : 0                   |
|                {0} | 0 0 0 |                            |
|                {1} | 0 0 0 |                            |
|                {1} | 0 0 0 |                            |
|                {1} | 0 0 0 |                            |
|                {1} | 1 0 0 |                            |
|                {1} | 0 1 0 |                            |
|                {1} | 0 0 1 |                            |
|                                                         |
|           9                     3                       |
|      1 : R  <----------------- R  : 1                   |
|                {1} | 0 0 0 |                            |
|                {1} | 0 0 0 |                            |
|                {1} | 0 0 0 |                            |
|                {2} | 0 0 0 |                            |
|                {2} | 0 0 0 |                            |
|                {2} | 0 0 0 |                            |
|                {2} | 1 0 0 |                            |
|                {2} | 0 1 0 |                            |
|                {2} | 0 0 1 |                            |
|                                                         |
|           5                 1                           |
|      2 : R  <------------- R  : 2                       |
|                {2} | 0 |                                |
|                {2} | 0 |                                |
|                {2} | 0 |                                |
|                {3} | 0 |                                |
|                {3} | 1 |                                |
|                                                         |
|o46 : ComplexMap                                         |
+---------------------------------------------------------+
|i47 : h = canonicalMap(F', C, UseTarget=>false)          |
|                                                         |
|            2             1                              |
|o47 = -1 : R  <--------- R  : -1                         |
|                 | 1 |                                   |
|                 | 0 |                                   |
|                                                         |
|           7                     3                       |
|      0 : R  <----------------- R  : 0                   |
|                {0} | 0 0 0 |                            |
|                {1} | 1 0 0 |                            |
|                {1} | 0 1 0 |                            |
|                {1} | 0 0 1 |                            |
|                {1} | 0 0 0 |                            |
|                {1} | 0 0 0 |                            |
|                {1} | 0 0 0 |                            |
|                                                         |
|           9                     3                       |
|      1 : R  <----------------- R  : 1                   |
|                {1} | 0 0 0 |                            |
|                {1} | 0 0 0 |                            |
|                {1} | 0 0 0 |                            |
|                {2} | 1 0 0 |                            |
|                {2} | 0 1 0 |                            |
|                {2} | 0 0 1 |                            |
|                {2} | 0 0 0 |                            |
|                {2} | 0 0 0 |                            |
|                {2} | 0 0 0 |                            |
|                                                         |
|           5                 1                           |
|      2 : R  <------------- R  : 2                       |
|                {2} | 0 |                                |
|                {2} | 0 |                                |
|                {2} | 0 |                                |
|                {3} | 1 |                                |
|                {3} | 0 |                                |
|                                                         |
|o47 : ComplexMap                                         |
+---------------------------------------------------------+
|i48 : assert(isWellDefined g and isWellDefined h)        |
+---------------------------------------------------------+
|i49 : assert(g != h)                                     |
+---------------------------------------------------------+
|i50 : assert(isComplexMorphism g and isComplexMorphism h)|
+---------------------------------------------------------+

See also
========

  * inducedMap(Complex,Complex), --
    make the map of complexes induced at each term by the identity map

Ways to use canonicalMap :
==========================

  * "canonicalMap(Complex,Complex)"

For the programmer
==================

The object canonicalMap, is a method function with options (Macaulay2Doc).

canonicalTruncation(Complex,ZZ,ZZ) -- reducing the number of non-zero terms of a complex
****************************************************************************************

Synopsis
========

  * Function: canonicalTruncation,
  * Usage:
        canonicalTruncation(C, lo, hi)
  * Inputs:
      * C, a complex,
      * lo, an integer (Macaulay2Doc), or -infinity or null (the
        latter two give no lower bound)
      * hi, an integer (Macaulay2Doc), or infinity or null (the
        latter two give no upper bound)
  * Outputs:
      * a complex,

Description
===========

Returns a new complex which drops (sets to zero) all modules outside the given
range, and modifies the ends to preserve homology in the given range.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c,d,e];                                                  |
+-----------------------------------------------------------------------------+
|i2 : I = intersect(ideal(a,b),ideal(c,d,e))                                  |
|                                                                             |
|o2 = ideal (b*e, a*e, b*d, a*d, b*c, a*c)                                    |
|                                                                             |
|o2 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i3 : C = (dual freeResolution I)[-4]                                         |
|                                                                             |
|      1      5      9      6      1                                          |
|o3 = R  <-- R  <-- R  <-- R  <-- R                                           |
|                                                                             |
|     0      1      2      3      4                                           |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : C1 = canonicalTruncation(C, 1, 2)                                       |
|                                                                             |
|o4 = image {-4} | d c  0 b  0 0  a 0  0 0 | <-- cokernel {-3} | -b a  0  0   |
|           {-4} | e 0  c 0  b 0  0 a  0 0 |              {-3} | 0  0  -b a   |
|           {-4} | 0 -e d 0  0 b  0 0  a 0 |              {-3} | -d 0  c  0   |
|           {-4} | 0 0  0 -e d -c 0 0  0 a |              {-3} | 0  -d 0  c   |
|           {-4} | 0 0  0 0  0 0  e -d c b |              {-3} | 0  0  0  0   |
|                                                         {-3} | -e 0  0  0   |
|     1                                                   {-3} | 0  -e 0  0   |
|                                                         {-3} | 0  0  -e 0   |
|                                                         {-3} | 0  0  0  -e  |
|                                                                             |
|                                                2                            |
|                                                                             |
|o4 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|0  0 |                                                                       |
|0  0 |                                                                       |
|0  0 |                                                                       |
|0  0 |                                                                       |
|-b a |                                                                       |
|c  0 |                                                                       |
|0  c |                                                                       |
|d  0 |                                                                       |
|0  d |                                                                       |
+-----------------------------------------------------------------------------+
|i5 : assert isWellDefined C1                                                 |
+-----------------------------------------------------------------------------+
|i6 : HH C1                                                                   |
|                                                                             |
|o6 = subquotient ({-4} | d c  0 b  0 0  a 0  0 0 |, {-4} | d -c -b a 0  0  0 |
|                  {-4} | e 0  c 0  b 0  0 a  0 0 |  {-4} | e 0  0  0 -c -b a |
|                  {-4} | 0 -e d 0  0 b  0 0  a 0 |  {-4} | 0 e  0  0 -d 0  0 |
|                  {-4} | 0 0  0 -e d -c 0 0  0 a |  {-4} | 0 0  e  0 0  -d 0 |
|                  {-4} | 0 0  0 0  0 0  e -d c b |  {-4} | 0 0  0  e 0  0  -d|
|                                                                             |
|     1                                                                       |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o6 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|0  0 |) <-- subquotient ({-3} | c b a  0  0  0  0 |, {-3} | -b a  0  0  0  0 |
|0  0 |                   {-3} | d 0 0  b  0  a  0 |  {-3} | 0  0  -b a  0  0 |
|-b a |                   {-3} | 0 d 0  -c 0  0  0 |  {-3} | -d 0  c  0  0  0 |
|c  0 |                   {-3} | 0 0 -d 0  0  c  0 |  {-3} | 0  -d 0  c  0  0 |
|0  c |                   {-3} | e 0 0  0  b  0  a |  {-3} | 0  0  0  0  -b a |
|                         {-3} | 0 e 0  0  -c 0  0 |  {-3} | -e 0  0  0  c  0 |
|                         {-3} | 0 0 -e 0  0  0  c |  {-3} | 0  -e 0  0  0  c |
|                         {-3} | 0 0 0  e  -d 0  0 |  {-3} | 0  0  -e 0  d  0 |
|                         {-3} | 0 0 0  0  0  -e d |  {-3} | 0  0  0  -e 0  d |
|                                                                             |
|            2                                                                |
|-----------------------------------------------------------------------------|
||)                                                                           |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i7 : naiveTruncation(HH C, 1, 2) == HH C1                                    |
|                                                                             |
|o7 = true                                                                    |
+-----------------------------------------------------------------------------+
|i8 : prune HH C1                                                             |
|                                                                             |
|o8 = cokernel {-3} | e d c | <-- cokernel {-2} | b a |                       |
|                                                                             |
|     1                           2                                           |
|                                                                             |
|o8 : Complex                                                                 |
+-----------------------------------------------------------------------------+

We illustrate various possibilities for the truncation interval.

+-----------------------------------------------------------------+
|i9 : C2 = canonicalTruncation(C, 1, 6)                           |
|                                                                 |
|                                                 9      6      1 |
|o9 = image {-4} | d c  0 b  0 0  a 0  0 0 | <-- R  <-- R  <-- R  |
|           {-4} | e 0  c 0  b 0  0 a  0 0 |                      |
|           {-4} | 0 -e d 0  0 b  0 0  a 0 |     2      3      4  |
|           {-4} | 0 0  0 -e d -c 0 0  0 a |                      |
|           {-4} | 0 0  0 0  0 0  e -d c b |                      |
|                                                                 |
|     1                                                           |
|                                                                 |
|o9 : Complex                                                     |
+-----------------------------------------------------------------+
|i10 : assert isWellDefined C2                                    |
+-----------------------------------------------------------------+
|i11 : C3 = canonicalTruncation(C, 1, infinity)                   |
|                                                                 |
|                                                  9      6      1|
|o11 = image {-4} | d c  0 b  0 0  a 0  0 0 | <-- R  <-- R  <-- R |
|            {-4} | e 0  c 0  b 0  0 a  0 0 |                     |
|            {-4} | 0 -e d 0  0 b  0 0  a 0 |     2      3      4 |
|            {-4} | 0 0  0 -e d -c 0 0  0 a |                     |
|            {-4} | 0 0  0 0  0 0  e -d c b |                     |
|                                                                 |
|      1                                                          |
|                                                                 |
|o11 : Complex                                                    |
+-----------------------------------------------------------------+
|i12 : C2 == C3                                                   |
|                                                                 |
|o12 = true                                                       |
+-----------------------------------------------------------------+
|i13 : C4 = canonicalTruncation(C, -13, 2)                        |
|                                                                 |
|       1      5                                                  |
|o13 = R  <-- R  <-- cokernel {-3} | -b a  0  0  0  0 |           |
|                             {-3} | 0  0  -b a  0  0 |           |
|      0      1               {-3} | -d 0  c  0  0  0 |           |
|                             {-3} | 0  -d 0  c  0  0 |           |
|                             {-3} | 0  0  0  0  -b a |           |
|                             {-3} | -e 0  0  0  c  0 |           |
|                             {-3} | 0  -e 0  0  0  c |           |
|                             {-3} | 0  0  -e 0  d  0 |           |
|                             {-3} | 0  0  0  -e 0  d |           |
|                                                                 |
|                    2                                            |
|                                                                 |
|o13 : Complex                                                    |
+-----------------------------------------------------------------+
|i14 : C5 = canonicalTruncation(C, -infinity, 2)                  |
|                                                                 |
|       1      5                                                  |
|o14 = R  <-- R  <-- cokernel {-3} | -b a  0  0  0  0 |           |
|                             {-3} | 0  0  -b a  0  0 |           |
|      0      1               {-3} | -d 0  c  0  0  0 |           |
|                             {-3} | 0  -d 0  c  0  0 |           |
|                             {-3} | 0  0  0  0  -b a |           |
|                             {-3} | -e 0  0  0  c  0 |           |
|                             {-3} | 0  -e 0  0  0  c |           |
|                             {-3} | 0  0  -e 0  d  0 |           |
|                             {-3} | 0  0  0  -e 0  d |           |
|                                                                 |
|                    2                                            |
|                                                                 |
|o14 : Complex                                                    |
+-----------------------------------------------------------------+
|i15 : C4 == C5                                                   |
|                                                                 |
|o15 = true                                                       |
+-----------------------------------------------------------------+
|i16 : C6 = canonicalTruncation(C, , 2)                           |
|                                                                 |
|       1      5                                                  |
|o16 = R  <-- R  <-- cokernel {-3} | -b a  0  0  0  0 |           |
|                             {-3} | 0  0  -b a  0  0 |           |
|      0      1               {-3} | -d 0  c  0  0  0 |           |
|                             {-3} | 0  -d 0  c  0  0 |           |
|                             {-3} | 0  0  0  0  -b a |           |
|                             {-3} | -e 0  0  0  c  0 |           |
|                             {-3} | 0  -e 0  0  0  c |           |
|                             {-3} | 0  0  -e 0  d  0 |           |
|                             {-3} | 0  0  0  -e 0  d |           |
|                                                                 |
|                    2                                            |
|                                                                 |
|o16 : Complex                                                    |
+-----------------------------------------------------------------+
|i17 : C4 == C6                                                   |
|                                                                 |
|o17 = true                                                       |
+-----------------------------------------------------------------+

If the lower and upper bounds are equal in the canonical truncation, the
resulting complex has a single nonzero term consisting of the homology in that
location.

+-------------------------------------------------------------------------+
|i18 : assert(canonicalTruncation(C, 1, 1) == naiveTruncation(HH C, 1, 1))|
+-------------------------------------------------------------------------+

If we truncate only from below, then we get an injection from the truncation
into the original complex, whereas if we truncate only from above, we get a
surjection onto the truncated complex.

+-----------------------------------------------------------------------------+
|i19 : f = inducedMap(C, C3)                                                  |
|                                                                             |
|           5                                                                 |
|o19 = 1 : R  <------------------------------------ image {-4} | d c  0 b  0  |
|                {-4} | d c  0 b  0 0  a 0  0 0 |         {-4} | e 0  c 0  b  |
|                {-4} | e 0  c 0  b 0  0 a  0 0 |         {-4} | 0 -e d 0  0  |
|                {-4} | 0 -e d 0  0 b  0 0  a 0 |         {-4} | 0 0  0 -e d  |
|                {-4} | 0 0  0 -e d -c 0 0  0 a |         {-4} | 0 0  0 0  0  |
|                {-4} | 0 0  0 0  0 0  e -d c b |                             |
|                                                                             |
|           9                                  9                              |
|      2 : R  <------------------------------ R  : 2                          |
|                {-3} | 1 0 0 0 0 0 0 0 0 |                                   |
|                {-3} | 0 1 0 0 0 0 0 0 0 |                                   |
|                {-3} | 0 0 1 0 0 0 0 0 0 |                                   |
|                {-3} | 0 0 0 1 0 0 0 0 0 |                                   |
|                {-3} | 0 0 0 0 1 0 0 0 0 |                                   |
|                {-3} | 0 0 0 0 0 1 0 0 0 |                                   |
|                {-3} | 0 0 0 0 0 0 1 0 0 |                                   |
|                {-3} | 0 0 0 0 0 0 0 1 0 |                                   |
|                {-3} | 0 0 0 0 0 0 0 0 1 |                                   |
|                                                                             |
|           6                            6                                    |
|      3 : R  <------------------------ R  : 3                                |
|                {-2} | 1 0 0 0 0 0 |                                         |
|                {-2} | 0 1 0 0 0 0 |                                         |
|                {-2} | 0 0 1 0 0 0 |                                         |
|                {-2} | 0 0 0 1 0 0 |                                         |
|                {-2} | 0 0 0 0 1 0 |                                         |
|                {-2} | 0 0 0 0 0 1 |                                         |
|                                                                             |
|           1             1                                                   |
|      4 : R  <--------- R  : 4                                               |
|                | 1 |                                                        |
|                                                                             |
|o19 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|0  a 0  0 0 | : 1                                                            |
|0  0 a  0 0 |                                                                |
|b  0 0  a 0 |                                                                |
|-c 0 0  0 a |                                                                |
|0  e -d c b |                                                                |
+-----------------------------------------------------------------------------+
|i20 : assert isWellDefined f                                                 |
+-----------------------------------------------------------------------------+
|i21 : assert(ker f == 0)                                                     |
+-----------------------------------------------------------------------------+
|i22 : prune coker f                                                          |
|                                                                             |
|       1                                                                     |
|o22 = R  <-- cokernel {-4} | d c  0 b  0 0  a 0  0 0 |                       |
|                      {-4} | e 0  c 0  b 0  0 a  0 0 |                       |
|      0               {-4} | 0 -e d 0  0 b  0 0  a 0 |                       |
|                      {-4} | 0 0  0 -e d -c 0 0  0 a |                       |
|                      {-4} | 0 0  0 0  0 0  e -d c b |                       |
|                                                                             |
|             1                                                               |
|                                                                             |
|o22 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i23 : C7 = canonicalTruncation(C, -infinity, 1)                              |
|                                                                             |
|       1                                                                     |
|o23 = R  <-- cokernel {-4} | d -c -b a 0  0  0  0  0 |                       |
|                      {-4} | e 0  0  0 -c -b a  0  0 |                       |
|      0               {-4} | 0 e  0  0 -d 0  0  -b a |                       |
|                      {-4} | 0 0  e  0 0  -d 0  c  0 |                       |
|                      {-4} | 0 0  0  e 0  0  -d 0  c |                       |
|                                                                             |
|             1                                                               |
|                                                                             |
|o23 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i24 : C7 != coker f                                                          |
|                                                                             |
|o24 = true                                                                   |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i25 : g = inducedMap(C5, C)                                                  |
|                                                                             |
|           1                  1                                              |
|o25 = 0 : R  <-------------- R  : 0                                          |
|                {-5} | 1 |                                                   |
|                                                                             |
|           5                          5                                      |
|      1 : R  <---------------------- R  : 1                                  |
|                {-4} | 1 0 0 0 0 |                                           |
|                {-4} | 0 1 0 0 0 |                                           |
|                {-4} | 0 0 1 0 0 |                                           |
|                {-4} | 0 0 0 1 0 |                                           |
|                {-4} | 0 0 0 0 1 |                                           |
|                                                                             |
|                                                                             |
|      2 : cokernel {-3} | -b a  0  0  0  0 | <------------------------------ |
|                   {-3} | 0  0  -b a  0  0 |    {-3} | 1 0 0 0 0 0 0 0 0 |   |
|                   {-3} | -d 0  c  0  0  0 |    {-3} | 0 1 0 0 0 0 0 0 0 |   |
|                   {-3} | 0  -d 0  c  0  0 |    {-3} | 0 0 1 0 0 0 0 0 0 |   |
|                   {-3} | 0  0  0  0  -b a |    {-3} | 0 0 0 1 0 0 0 0 0 |   |
|                   {-3} | -e 0  0  0  c  0 |    {-3} | 0 0 0 0 1 0 0 0 0 |   |
|                   {-3} | 0  -e 0  0  0  c |    {-3} | 0 0 0 0 0 1 0 0 0 |   |
|                   {-3} | 0  0  -e 0  d  0 |    {-3} | 0 0 0 0 0 0 1 0 0 |   |
|                   {-3} | 0  0  0  -e 0  d |    {-3} | 0 0 0 0 0 0 0 1 0 |   |
|                                                {-3} | 0 0 0 0 0 0 0 0 1 |   |
|                                                                             |
|o25 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
| 9                                                                           |
|R  : 2                                                                       |
+-----------------------------------------------------------------------------+
|i26 : assert isWellDefined g                                                 |
+-----------------------------------------------------------------------------+
|i27 : assert(coker g == 0)                                                   |
+-----------------------------------------------------------------------------+
|i28 : C8 = canonicalTruncation(C, 2, infinity)                               |
|                                                                             |
|                                            6      1                         |
|o28 = image {-3} | c b a  0  0  0  0 | <-- R  <-- R                          |
|            {-3} | d 0 0  b  0  a  0 |                                       |
|            {-3} | 0 d 0  -c 0  0  0 |     3      4                          |
|            {-3} | 0 0 -d 0  0  c  0 |                                       |
|            {-3} | e 0 0  0  b  0  a |                                       |
|            {-3} | 0 e 0  0  -c 0  0 |                                       |
|            {-3} | 0 0 -e 0  0  0  c |                                       |
|            {-3} | 0 0 0  e  -d 0  0 |                                       |
|            {-3} | 0 0 0  0  0  -e d |                                       |
|                                                                             |
|      2                                                                      |
|                                                                             |
|o28 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i29 : prune C8                                                               |
|                                                                             |
|                                   6      1                                  |
|o29 = cokernel {-2} | b  a  | <-- R  <-- R                                   |
|               {-2} | -c 0  |                                                |
|               {-2} | 0  -c |     3      4                                   |
|               {-2} | -d 0  |                                                |
|               {-2} | -e 0  |                                                |
|               {-2} | 0  -d |                                                |
|               {-2} | 0  -e |                                                |
|                                                                             |
|      2                                                                      |
|                                                                             |
|o29 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i30 : prune ker g                                                            |
|                                                                             |
|                                 6      1                                    |
|o30 = cokernel {-2} | ac  | <-- R  <-- R                                     |
|               {-2} | -bc |                                                  |
|               {-2} | ad  |     3      4                                     |
|               {-2} | ae  |                                                  |
|               {-2} | -bd |                                                  |
|               {-2} | -be |                                                  |
|                                                                             |
|      2                                                                      |
|                                                                             |
|o30 : Complex                                                                |
+-----------------------------------------------------------------------------+

There is another type of truncation, see naiveTruncation,
which yields a short exact sequence of
complexes.

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * canonicalTruncation(ComplexMap,Sequence)
    -- reducing the number of
    non-zero terms of a complex
  * naiveTruncation(Complex,ZZ,ZZ)
    -- drops all terms of a complex
    outside a given interval
  * naiveTruncation(ComplexMap,ZZ,ZZ)
    -- drops all terms in the source
    of a complex outside a given interval
  * truncate(List,Complex) -- truncation
    of a complex at a specified degree or set of degrees

Ways to use this method:
========================

  * "canonicalTruncation(Complex,InfiniteNumber,InfiniteNumber)"
  * "canonicalTruncation(Complex,InfiniteNumber,ZZ)"
  * "canonicalTruncation(Complex,Nothing,ZZ)"
  * "canonicalTruncation(Complex,Sequence)"
  * "canonicalTruncation(Complex,ZZ,InfiniteNumber)"
  * "canonicalTruncation(Complex,ZZ,Nothing)"
  * canonicalTruncation(Complex,ZZ,ZZ)
    -- reducing the number of
    non-zero terms of a complex

canonicalTruncation(ComplexMap,ZZ,ZZ) -- reducing the number of non-zero terms of a complex
*******************************************************************************************

Synopsis
========

  * Function: canonicalTruncation,
  * Usage:
        canonicalTruncation(f, (lo, hi))
  * Inputs:
      * f, a map of complexes,
      * lo, an integer (Macaulay2Doc), or -infinity or null (the
        latter two give no lower bound)
      * hi, an integer (Macaulay2Doc), or infinity or null (the
        latter two give no upper bound)
  * Outputs:
      * a map of complexes,

Description
===========

Returns a new complex map which drops (sets to zero) all modules outside the
given range in the source, and modifies the ends to preserve homology in the
given range.  The degree of the map f is used to determine the truncation of
the target.

First, we define some non-trivial maps of chain complexes.

+---------------------------------------------------------------------------+
|i1 : R = ZZ/101[a..d];                                                     |
+---------------------------------------------------------------------------+
|i2 : C = (freeResolution coker matrix{{a,b,c}})[1]                         |
|                                                                           |
|      1      3      3      1                                               |
|o2 = R  <-- R  <-- R  <-- R                                                |
|                                                                           |
|     -1     0      1      2                                                |
|                                                                           |
|o2 : Complex                                                               |
+---------------------------------------------------------------------------+
|i3 : D = freeResolution coker matrix{{a*b,a*c,b*c}}                        |
|                                                                           |
|      1      3      2                                                      |
|o3 = R  <-- R  <-- R                                                       |
|                                                                           |
|     0      1      2                                                       |
|                                                                           |
|o3 : Complex                                                               |
+---------------------------------------------------------------------------+
|i4 : E = freeResolution coker matrix{{a^2,b^2,c*d}}                        |
|                                                                           |
|      1      3      3      1                                               |
|o4 = R  <-- R  <-- R  <-- R                                                |
|                                                                           |
|     0      1      2      3                                                |
|                                                                           |
|o4 : Complex                                                               |
+---------------------------------------------------------------------------+
|i5 : f = randomComplexMap(D, C)                                            |
|                                                                           |
|                    1                                                      |
|o5 = -1 : 0 <----- R  : -1                                                 |
|               0                                                           |
|                                                                           |
|          1                                                           3    |
|     0 : R  <------------------------------------------------------- R  : 0|
|               | 24a-36b-30c-29d 19a+19b-10c-29d -8a-22b-29c-24d |         |
|                                                                           |
|          3                          3                                     |
|     1 : R  <---------------------- R  : 1                                 |
|               {2} | -38 21 -47 |                                          |
|               {2} | -16 34 -39 |                                          |
|               {2} | 39  19 -18 |                                          |
|                                                                           |
|          2                   1                                            |
|     2 : R  <--------------- R  : 2                                        |
|               {3} | -13 |                                                 |
|               {3} | -43 |                                                 |
|                                                                           |
|o5 : ComplexMap                                                            |
+---------------------------------------------------------------------------+
|i6 : g = randomComplexMap(E, D)                                            |
|                                                                           |
|          1               1                                                |
|o6 = 0 : R  <----------- R  : 0                                            |
|               | -15 |                                                     |
|                                                                           |
|          3                          3                                     |
|     1 : R  <---------------------- R  : 1                                 |
|               {2} | -28 2  45  |                                          |
|               {2} | -47 16 -34 |                                          |
|               {2} | 38  22 -48 |                                          |
|                                                                           |
|          3         2                                                      |
|     2 : R  <----- R  : 2                                                  |
|               0                                                           |
|                                                                           |
|o6 : ComplexMap                                                            |
+---------------------------------------------------------------------------+
|i7 : h = g * f                                                             |
|                                                                           |
|          1                                                           3    |
|o7 = 0 : R  <------------------------------------------------------- R  : 0|
|               | 44a+35b+46c+31d 18a+18b+49c+31d 19a+27b+31c-44d |         |
|                                                                           |
|          3                          3                                     |
|     1 : R  <---------------------- R  : 1                                 |
|               {2} | -41 32 24  |                                          |
|               {2} | 2   22 -25 |                                          |
|               {2} | -32 28 38  |                                          |
|                                                                           |
|o7 : ComplexMap                                                            |
+---------------------------------------------------------------------------+

We use these maps to illustrate canonical truncation.

+-----------------------------------------------------------------------------+
|i8 : tf = canonicalTruncation(f, (0, 1))                                     |
|                                                                             |
|          1                                                                  |
|o8 = 0 : R  <----------------------------------------------------------------|
|               | 19a2-5ab+36b2-10ac+30bc-29ad+29bd -8ab-22b2-19ac-48bc+10c2-2|
|                                                                             |
|                                                                             |
|     1 : cokernel {2} | -c 0  | <---------------------- cokernel {2} | -c | :|
|                  {2} | b  -b |    {2} | -38 21 -47 |            {2} | b  |  |
|                  {2} | 0  a  |    {2} | -16 34 -39 |            {2} | -a |  |
|                                   {2} | 39  19 -18 |                        |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|----------------------------------------------- image {1} | -b 0  -c | : 0   |
|4bd+29cd -8a2-22ab+48ac+36bc+30c2-24ad+29cd |         {1} | a  -c 0  |       |
|                                                      {1} | 0  b  a  |       |
|                                                                             |
| 1                                                                           |
+-----------------------------------------------------------------------------+
|i9 : tg = canonicalTruncation(g, (0, 1))                                     |
|                                                                             |
|          1               1                                                  |
|o9 = 0 : R  <----------- R  : 0                                              |
|               | -15 |                                                       |
|                                                                             |
|     1 : cokernel {2} | -b2 -cd 0   | <---------------------- cokernel {2} | |
|                  {2} | a2  0   -cd |    {2} | -28 2  45  |            {2} | |
|                  {2} | 0   a2  b2  |    {2} | -47 16 -34 |            {2} | |
|                                         {2} | 38  22 -48 |                  |
|                                                                             |
|o9 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|-c 0  | : 1                                                                  |
|b  -b |                                                                      |
|0  a  |                                                                      |
+-----------------------------------------------------------------------------+
|i10 : th = canonicalTruncation(h, (0, 1))                                    |
|                                                                             |
|           1                                                                 |
|o10 = 0 : R  <---------------------------------------------------------------|
|                | 18a2-26ab-35b2+49ac-46bc+31ad-31bd 19ab+27b2-18ac+13bc-49c2|
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | -b2 -cd 0   | <---------------------- cokernel {2} ||
|                   {2} | a2  0   -cd |    {2} | -41 32 24  |            {2} ||
|                   {2} | 0   a2  b2  |    {2} | 2   22 -25 |            {2} ||
|                                          {2} | -32 28 38  |                 |
|                                                                             |
|o10 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|------------------------------------------------- image {1} | -b 0  -c | : 0 |
|-44bd-31cd 19a2+27ab-13ac-35bc-46c2-44ad-31cd |         {1} | a  -c 0  |     |
|                                                        {1} | 0  b  a  |     |
|                                                                             |
| -c | : 1                                                                    |
| b  |                                                                        |
| -a |                                                                        |
+-----------------------------------------------------------------------------+
|i11 : assert all({tf, tg, th}, isWellDefined)                                |
+-----------------------------------------------------------------------------+
|i12 : assert(th == tg * tf)                                                  |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i13 : t2f = canonicalTruncation(f, (-infinity, 1))                           |
|                                                                             |
|           1                                                           3     |
|o13 = 0 : R  <------------------------------------------------------- R  : 0 |
|                | 24a-36b-30c-29d 19a+19b-10c-29d -8a-22b-29c-24d |          |
|                                                                             |
|      1 : cokernel {2} | -c 0  | <---------------------- cokernel {2} | -c | |
|                   {2} | b  -b |    {2} | -38 21 -47 |            {2} | b  | |
|                   {2} | 0  a  |    {2} | -16 34 -39 |            {2} | -a | |
|                                    {2} | 39  19 -18 |                       |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|: 1                                                                          |
+-----------------------------------------------------------------------------+
|i14 : assert(t2f == canonicalTruncation(f, (, 1)))                           |
+-----------------------------------------------------------------------------+
|i15 : assert(tf != t2f)                                                      |
+-----------------------------------------------------------------------------+

There is another type of truncation, see naive truncation,
which yields a short exact sequence
of complexes.

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * canonicalTruncation(Complex,Sequence)
    -- reducing the number of
    non-zero terms of a complex
  * naiveTruncation(Complex,ZZ,ZZ)
    -- drops all terms of a complex
    outside a given interval
  * naiveTruncation(ComplexMap,ZZ,ZZ)
    -- drops all terms in the source
    of a complex outside a given interval
  * truncate(List,ComplexMap), --
    truncation of a complex map at a specified degree or set of degrees

Ways to use this method:
========================

  * "canonicalTruncation(ComplexMap,InfiniteNumber,InfiniteNumber)"
  * "canonicalTruncation(ComplexMap,InfiniteNumber,ZZ)"
  * "canonicalTruncation(ComplexMap,Nothing,ZZ)"
  * "canonicalTruncation(ComplexMap,Sequence)"
  * "canonicalTruncation(ComplexMap,ZZ,InfiniteNumber)"
  * "canonicalTruncation(ComplexMap,ZZ,Nothing)"
  * canonicalTruncation(ComplexMap,ZZ,ZZ)
    -- reducing the number of
    non-zero terms of a complex

chainComplex(Complex) -- translate between data types for chain complexes
*************************************************************************

Synopsis
========

  * Function: chainComplex (Macaulay2Doc),
  * Usage:
        C = chainComplex D
  * Inputs:
      * D, a complex,
  * Outputs:
      * C, a chain complex (Macaulay2Doc),

Description
===========

Both ChainComplex and Complex are Macaulay2 types that implement chain
complexes of modules over rings. The plan is to replace ChainComplex with this
new type. Before this happens, this function allows interoperability between
these types.

The first example is the minimal free resolution of the twisted cubic curve.

+------------------------------------------+
|i1 : R = ZZ/32003[a..d];                  |
+------------------------------------------+
|i2 : I = monomialCurveIdeal(R, {1,2,3})   |
|                                          |
|             2                    2       |
|o2 = ideal (c  - b*d, b*c - a*d, b  - a*c)|
|                                          |
|o2 : Ideal of R                           |
+------------------------------------------+
|i3 : M = R^1/I                            |
|                                          |
|o3 = cokernel | c2-bd bc-ad b2-ac |       |
|                                          |
|                            1             |
|o3 : R-module, quotient of R              |
+------------------------------------------+
|i4 : C = resolution M                     |
|                                          |
|      1      3      2                     |
|o4 = R  <-- R  <-- R  <-- 0               |
|                                          |
|     0      1      2      3               |
|                                          |
|o4 : ChainComplex                         |
+------------------------------------------+
|i5 : D = freeResolution M                 |
|                                          |
|      1      3      2                     |
|o5 = R  <-- R  <-- R                      |
|                                          |
|     0      1      2                      |
|                                          |
|o5 : Complex                              |
+------------------------------------------+
|i6 : C1 = chainComplex D                  |
|                                          |
|      1      3      2                     |
|o6 = R  <-- R  <-- R                      |
|                                          |
|     0      1      2                      |
|                                          |
|o6 : ChainComplex                         |
+------------------------------------------+
|i7 : assert(C == C1)                      |
+------------------------------------------+

The tensor products make the same choice of signs.

+-------------------------------------+
|i8 : D2 = D ** D                     |
|                                     |
|      1      6      13      12      4|
|o8 = R  <-- R  <-- R   <-- R   <-- R |
|                                     |
|     0      1      2       3       4 |
|                                     |
|o8 : Complex                         |
+-------------------------------------+
|i9 : C2 = chainComplex D2            |
|                                     |
|      1      6      13      12      4|
|o9 = R  <-- R  <-- R   <-- R   <-- R |
|                                     |
|     0      1      2       3       4 |
|                                     |
|o9 : ChainComplex                    |
+-------------------------------------+
|i10 : assert(C2 == C1 ** C1)         |
+-------------------------------------+

Caveat
======

This is a temporary method to allow comparisons among the data types, and will
be removed once the older data structure is replaced

See also
========

  * complex(ChainComplex) -- translate
    between data types for chain complexes
  * complex(ChainComplexMap) -- translate
    between data types for chain complex maps
  * chainComplex(ComplexMap) -- translate
    between data types for chain complexes

Ways to use this method:
========================

  * chainComplex(Complex) -- translate
    between data types for chain complexes

chainComplex(ComplexMap) -- translate between data types for chain complexes
****************************************************************************

Synopsis
========

  * Function: chainComplex (Macaulay2Doc),
  * Usage:
        f = chainComplex g
  * Inputs:
      * g, a map of complexes,
  * Outputs:
      * f, a chain complex map (Macaulay2Doc),

Description
===========

Both ChainComplexMap and ComplexMap are Macaulay2 types that implement maps
between chain complexes. The plan is to replace ChainComplexMap with this new
type. Before this happens, this function allows interoperability between these
types.

The first example is the minimal free resolution of the twisted cubic curve.

+---------------------------------------------+
|i1 : R = ZZ/101[a..d];                       |
+---------------------------------------------+
|i2 : I = monomialCurveIdeal(R, {1,2,3})      |
|                                             |
|             2                    2          |
|o2 = ideal (c  - b*d, b*c - a*d, b  - a*c)   |
|                                             |
|o2 : Ideal of R                              |
+---------------------------------------------+
|i3 : M = R^1/I                               |
|                                             |
|o3 = cokernel | c2-bd bc-ad b2-ac |          |
|                                             |
|                            1                |
|o3 : R-module, quotient of R                 |
+---------------------------------------------+
|i4 : D = freeResolution M                    |
|                                             |
|      1      3      2                        |
|o4 = R  <-- R  <-- R                         |
|                                             |
|     0      1      2                         |
|                                             |
|o4 : Complex                                 |
+---------------------------------------------+
|i5 : C = resolution M                        |
|                                             |
|      1      3      2                        |
|o5 = R  <-- R  <-- R  <-- 0                  |
|                                             |
|     0      1      2      3                  |
|                                             |
|o5 : ChainComplex                            |
+---------------------------------------------+
|i6 : g = D.dd                                |
|                                             |
|          1                             3    |
|o6 = 0 : R  <------------------------- R  : 1|
|               | b2-ac bc-ad c2-bd |         |
|                                             |
|          3                     2            |
|     1 : R  <----------------- R  : 2        |
|               {2} | -c d  |                 |
|               {2} | b  -c |                 |
|               {2} | -a b  |                 |
|                                             |
|o6 : ComplexMap                              |
+---------------------------------------------+
|i7 : f = chainComplex g                      |
|                                             |
|          1                             3    |
|o7 = 0 : R  <------------------------- R  : 1|
|               | b2-ac bc-ad c2-bd |         |
|                                             |
|          3                     2            |
|     1 : R  <----------------- R  : 2        |
|               {2} | -c d  |                 |
|               {2} | b  -c |                 |
|               {2} | -a b  |                 |
|                                             |
|o7 : ChainComplexMap                         |
+---------------------------------------------+
|i8 : assert(f == C.dd)                       |
+---------------------------------------------+

We construct a random morphism of chain complexes.

+---------------------------------------------------------------------------+
|i9 : J = ideal vars R                                                      |
|                                                                           |
|o9 = ideal (a, b, c, d)                                                    |
|                                                                           |
|o9 : Ideal of R                                                            |
+---------------------------------------------------------------------------+
|i10 : C1 = resolution(R^1/J)                                               |
|                                                                           |
|       1      4      6      4      1                                       |
|o10 = R  <-- R  <-- R  <-- R  <-- R  <-- 0                                 |
|                                                                           |
|      0      1      2      3      4      5                                 |
|                                                                           |
|o10 : ChainComplex                                                         |
+---------------------------------------------------------------------------+
|i11 : D1 = freeResolution(R^1/J)                                           |
|                                                                           |
|       1      4      6      4      1                                       |
|o11 = R  <-- R  <-- R  <-- R  <-- R                                        |
|                                                                           |
|      0      1      2      3      4                                        |
|                                                                           |
|o11 : Complex                                                              |
+---------------------------------------------------------------------------+
|i12 : g = randomComplexMap(D1, D, Cycle => true)                           |
|                                                                           |
|           1               1                                               |
|o12 = 0 : R  <----------- R  : 0                                           |
|                | -16 |                                                    |
|                                                                           |
|           4                                                          3    |
|      1 : R  <------------------------------------------------------ R  : 1|
|                {1} | -19b+45c-34d    -19b+8c-3d  -10b-22c-47d   |         |
|                {1} | 19a-16b+24c+39d 19a+22c+29d 10a-39c+29d    |         |
|                {1} | -29a-24b-15d    -8a-38b-28d 22a+39b-16c-7d |         |
|                {1} | 34a-39b+15c     19a-29b+28c 47a-13b+7c     |         |
|                                                                           |
|           6                                                 2             |
|      2 : R  <--------------------------------------------- R  : 2         |
|                {2} | -10a+19b+44c+36d 10b+2c-24d       |                  |
|                {2} | -22a+30b+45c-22d b+8c+9d          |                  |
|                {2} | 24a-38b+24c+43d  21a+39b+22c+23d  |                  |
|                {2} | -47a-33b-12c     -11b+44c+34d     |                  |
|                {2} | -36a-29b-4c      -43a-13b-18c-39d |                  |
|                {2} | -29a-30b-15c     38a-47b-28c+15d  |                  |
|                                                                           |
|o12 : ComplexMap                                                           |
+---------------------------------------------------------------------------+
|i13 : f = chainComplex g                                                   |
|                                                                           |
|           1               1                                               |
|o13 = 0 : R  <----------- R  : 0                                           |
|                | -16 |                                                    |
|                                                                           |
|           4                                                          3    |
|      1 : R  <------------------------------------------------------ R  : 1|
|                {1} | -19b+45c-34d    -19b+8c-3d  -10b-22c-47d   |         |
|                {1} | 19a-16b+24c+39d 19a+22c+29d 10a-39c+29d    |         |
|                {1} | -29a-24b-15d    -8a-38b-28d 22a+39b-16c-7d |         |
|                {1} | 34a-39b+15c     19a-29b+28c 47a-13b+7c     |         |
|                                                                           |
|           6                                                 2             |
|      2 : R  <--------------------------------------------- R  : 2         |
|                {2} | -10a+19b+44c+36d 10b+2c-24d       |                  |
|                {2} | -22a+30b+45c-22d b+8c+9d          |                  |
|                {2} | 24a-38b+24c+43d  21a+39b+22c+23d  |                  |
|                {2} | -47a-33b-12c     -11b+44c+34d     |                  |
|                {2} | -36a-29b-4c      -43a-13b-18c-39d |                  |
|                {2} | -29a-30b-15c     38a-47b-28c+15d  |                  |
|                                                                           |
|o13 : ChainComplexMap                                                      |
+---------------------------------------------------------------------------+
|i14 : assert(g == complex f)                                               |
+---------------------------------------------------------------------------+
|i15 : assert(isComplexMorphism g)                                          |
+---------------------------------------------------------------------------+

Caveat
======

This is a temporary method to allow comparisons among the data types, and will
be removed once the older data structure is replaced

See also
========

  * complex(ChainComplexMap) -- translate
    between data types for chain complex maps
  * complex(ChainComplex) -- translate
    between data types for chain complexes
  * chainComplex(Complex) -- translate
    between data types for chain complexes

Ways to use this method:
========================

  * chainComplex(ComplexMap) -- translate
    between data types for chain complexes

coimage(ComplexMap) -- make the coimage of a map of complexes
*************************************************************

Synopsis
========

  * Function: coimage (Macaulay2Doc),
  * Usage:
        coimage f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * a complex,

Description
===========

The coimage of a chain complex map $f : C \to D$ is the complex $E$ whose
$i-th$ term is $coimage(f_i)$, and whose differential is induced from the
differential on the source.

In the following example, we first construct a random complex morphism $f : C
\to D$.  We consider the exact sequence $0 \to D \to cone(f) \to C[-1] \to 0$.
For the maps $g : D \to cone(f)$ and $h : cone(f) \to C[-1]$, we compute the
coimage.

+--------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c,d];                                           |
+--------------------------------------------------------------------+
|i2 : C = freeResolution ideal(b^2-a*c, b*c-a*d, c^2-b*d)            |
|                                                                    |
|      1      3      2                                               |
|o2 = S  <-- S  <-- S                                                |
|                                                                    |
|     0      1      2                                                |
|                                                                    |
|o2 : Complex                                                        |
+--------------------------------------------------------------------+
|i3 : D = freeResolution ideal(a,b,c)                                |
|                                                                    |
|      1      3      3      1                                        |
|o3 = S  <-- S  <-- S  <-- S                                         |
|                                                                    |
|     0      1      2      3                                         |
|                                                                    |
|o3 : Complex                                                        |
+--------------------------------------------------------------------+
|i4 : f = randomComplexMap(D, C, Cycle => true, InternalDegree => 0) |
|                                                                    |
|          1               1                                         |
|o4 = 0 : S  <----------- S  : 0                                     |
|               | -22 |                                              |
|                                                                    |
|          3                                                    3    |
|     1 : S  <------------------------------------------------ S  : 1|
|               {1} | 36b+3c       30b-19c+22d -29b-10c    |         |
|               {1} | -36a-22b+29c -30a-14c    29a+29c+22d |         |
|               {1} | 19a-29b      19a-8b      10a-29b-22c |         |
|                                                                    |
|          3                                                 2       |
|     2 : S  <--------------------------------------------- S  : 2   |
|               {2} | -29a-30b+31c-22d 29b+6c-36d       |            |
|               {2} | -10a+24b+3c      34b-19c+19d      |            |
|               {2} | 24a-8b+29c       -24a-29b-14c-29d |            |
|                                                                    |
|o4 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i5 : Cf = cone f                                                    |
|                                                                    |
|      1      4      6      3                                        |
|o5 = S  <-- S  <-- S  <-- S                                         |
|                                                                    |
|     0      1      2      3                                         |
|                                                                    |
|o5 : Complex                                                        |
+--------------------------------------------------------------------+
|i6 : g = canonicalMap(Cf, D)                                        |
|                                                                    |
|          1             1                                           |
|o6 = 0 : S  <--------- S  : 0                                       |
|               | 1 |                                                |
|                                                                    |
|          4                     3                                   |
|     1 : S  <----------------- S  : 1                               |
|               {0} | 0 0 0 |                                        |
|               {1} | 1 0 0 |                                        |
|               {1} | 0 1 0 |                                        |
|               {1} | 0 0 1 |                                        |
|                                                                    |
|          6                     3                                   |
|     2 : S  <----------------- S  : 2                               |
|               {2} | 0 0 0 |                                        |
|               {2} | 0 0 0 |                                        |
|               {2} | 0 0 0 |                                        |
|               {2} | 1 0 0 |                                        |
|               {2} | 0 1 0 |                                        |
|               {2} | 0 0 1 |                                        |
|                                                                    |
|          3                 1                                       |
|     3 : S  <------------- S  : 3                                   |
|               {3} | 0 |                                            |
|               {3} | 0 |                                            |
|               {3} | 1 |                                            |
|                                                                    |
|o6 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i7 : h = canonicalMap(C[-1], Cf)                                    |
|                                                                    |
|          1                   4                                     |
|o7 = 1 : S  <--------------- S  : 1                                 |
|               | 1 0 0 0 |                                          |
|                                                                    |
|          3                           6                             |
|     2 : S  <----------------------- S  : 2                         |
|               {2} | 1 0 0 0 0 0 |                                  |
|               {2} | 0 1 0 0 0 0 |                                  |
|               {2} | 0 0 1 0 0 0 |                                  |
|                                                                    |
|          2                     3                                   |
|     3 : S  <----------------- S  : 3                               |
|               {3} | 1 0 0 |                                        |
|               {3} | 0 1 0 |                                        |
|                                                                    |
|o7 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i8 : coimage g == D                                                 |
|                                                                    |
|o8 = true                                                           |
+--------------------------------------------------------------------+
|i9 : prune coimage h == C[-1]                                       |
|                                                                    |
|o9 = true                                                           |
+--------------------------------------------------------------------+

There is a canonical map of complexes from the source to the coimage.

+----------------------------------------------------------------+
|i10 : g1 = canonicalMap(coimage g, source g)                    |
|                                                                |
|           1             1                                      |
|o10 = 0 : S  <--------- S  : 0                                  |
|                | 1 |                                           |
|                                                                |
|           3                     3                              |
|      1 : S  <----------------- S  : 1                          |
|                {1} | 1 0 0 |                                   |
|                {1} | 0 1 0 |                                   |
|                {1} | 0 0 1 |                                   |
|                                                                |
|           3                     3                              |
|      2 : S  <----------------- S  : 2                          |
|                {2} | 1 0 0 |                                   |
|                {2} | 0 1 0 |                                   |
|                {2} | 0 0 1 |                                   |
|                                                                |
|           1                 1                                  |
|      3 : S  <------------- S  : 3                              |
|                {3} | 1 |                                       |
|                                                                |
|o10 : ComplexMap                                                |
+----------------------------------------------------------------+
|i11 : coimage g1 == coimage g                                   |
|                                                                |
|o11 = true                                                      |
+----------------------------------------------------------------+
|i12 : coker g1 == 0                                             |
|                                                                |
|o12 = true                                                      |
+----------------------------------------------------------------+
|i13 : h1 = canonicalMap(coimage h, source h)                    |
|                                                                |
|                                 1                              |
|o13 = 0 : cokernel | 1 | <----- S  : 0                          |
|                            0                                   |
|                                                                |
|                                                       4        |
|      1 : cokernel {0} | 0 0 0 | <------------------- S  : 1    |
|                   {1} | 1 0 0 |    {0} | 1 0 0 0 |             |
|                   {1} | 0 1 0 |    {1} | 0 0 0 0 |             |
|                   {1} | 0 0 1 |    {1} | 0 0 0 0 |             |
|                                    {1} | 0 0 0 0 |             |
|                                                                |
|                                                           6    |
|      2 : cokernel {2} | 0 0 0 | <----------------------- S  : 2|
|                   {2} | 0 0 0 |    {2} | 1 0 0 0 0 0 |         |
|                   {2} | 0 0 0 |    {2} | 0 1 0 0 0 0 |         |
|                   {2} | 1 0 0 |    {2} | 0 0 1 0 0 0 |         |
|                   {2} | 0 1 0 |    {2} | 0 0 0 0 0 0 |         |
|                   {2} | 0 0 1 |    {2} | 0 0 0 0 0 0 |         |
|                                    {2} | 0 0 0 0 0 0 |         |
|                                                                |
|                                                 3              |
|      3 : cokernel {3} | 0 | <----------------- S  : 3          |
|                   {3} | 0 |    {3} | 1 0 0 |                   |
|                   {3} | 1 |    {3} | 0 1 0 |                   |
|                                {3} | 0 0 0 |                   |
|                                                                |
|o13 : ComplexMap                                                |
+----------------------------------------------------------------+
|i14 : coimage h1 == coimage h                                   |
|                                                                |
|o14 = true                                                      |
+----------------------------------------------------------------+
|i15 : coker h1 == 0                                             |
|                                                                |
|o15 = true                                                      |
+----------------------------------------------------------------+

Caveat
======

The coimage is more computationally intensive than image(ComplexMap),
because, unlike image, it computes kernels of maps of
modules.

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * coimage (Macaulay2Doc) -- coimage of a map
  * image(ComplexMap) -- make the image of a map
    of complexes
  * kernel(ComplexMap) -- make the kernel of a
    map of complexes
  * cokernel(ComplexMap) -- make the cokernel
    of a map of complexes
  * canonicalMap -- gets the natural map arising from
    various constructions

Ways to use this method:
========================

  * coimage(ComplexMap) -- make the coimage of
    a map of complexes

cokernel(ComplexMap) -- make the cokernel of a map of complexes
***************************************************************

Synopsis
========

  * Function: cokernel (Macaulay2Doc),
  * Usage:
        cokernel f
        coker f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * a complex,

Description
===========

If $f : C \to D$ is a map of chain complexes of degree $d$, then the cokernel
is the complex $E$ whose $i-th$ is $cokernel(f_{i-d})$, and whose differential
is induced from the differential on the target.

In the following example, we first construct a random complex morphism $f : C
\to D$.  We consider the exact sequence $0 \to D \to cone(f) \to C[-1] \to 0$.
For the maps $g : D \to cone(f)$ and $h : cone(f) \to C[-1]$, we compute the
kernel.

+--------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c,d];                                           |
+--------------------------------------------------------------------+
|i2 : C = freeResolution ideal(b^2-a*c, b*c-a*d, c^2-b*d)            |
|                                                                    |
|      1      3      2                                               |
|o2 = S  <-- S  <-- S                                                |
|                                                                    |
|     0      1      2                                                |
|                                                                    |
|o2 : Complex                                                        |
+--------------------------------------------------------------------+
|i3 : D = freeResolution ideal(a,b,c)                                |
|                                                                    |
|      1      3      3      1                                        |
|o3 = S  <-- S  <-- S  <-- S                                         |
|                                                                    |
|     0      1      2      3                                         |
|                                                                    |
|o3 : Complex                                                        |
+--------------------------------------------------------------------+
|i4 : f = randomComplexMap(D, C, Cycle => true, InternalDegree => 0) |
|                                                                    |
|          1               1                                         |
|o4 = 0 : S  <----------- S  : 0                                     |
|               | -22 |                                              |
|                                                                    |
|          3                                                    3    |
|     1 : S  <------------------------------------------------ S  : 1|
|               {1} | 36b+3c       30b-19c+22d -29b-10c    |         |
|               {1} | -36a-22b+29c -30a-14c    29a+29c+22d |         |
|               {1} | 19a-29b      19a-8b      10a-29b-22c |         |
|                                                                    |
|          3                                                 2       |
|     2 : S  <--------------------------------------------- S  : 2   |
|               {2} | -29a-30b+31c-22d 29b+6c-36d       |            |
|               {2} | -10a+24b+3c      34b-19c+19d      |            |
|               {2} | 24a-8b+29c       -24a-29b-14c-29d |            |
|                                                                    |
|o4 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i5 : Cf = cone f                                                    |
|                                                                    |
|      1      4      6      3                                        |
|o5 = S  <-- S  <-- S  <-- S                                         |
|                                                                    |
|     0      1      2      3                                         |
|                                                                    |
|o5 : Complex                                                        |
+--------------------------------------------------------------------+
|i6 : g = canonicalMap(Cf, D)                                        |
|                                                                    |
|          1             1                                           |
|o6 = 0 : S  <--------- S  : 0                                       |
|               | 1 |                                                |
|                                                                    |
|          4                     3                                   |
|     1 : S  <----------------- S  : 1                               |
|               {0} | 0 0 0 |                                        |
|               {1} | 1 0 0 |                                        |
|               {1} | 0 1 0 |                                        |
|               {1} | 0 0 1 |                                        |
|                                                                    |
|          6                     3                                   |
|     2 : S  <----------------- S  : 2                               |
|               {2} | 0 0 0 |                                        |
|               {2} | 0 0 0 |                                        |
|               {2} | 0 0 0 |                                        |
|               {2} | 1 0 0 |                                        |
|               {2} | 0 1 0 |                                        |
|               {2} | 0 0 1 |                                        |
|                                                                    |
|          3                 1                                       |
|     3 : S  <------------- S  : 3                                   |
|               {3} | 0 |                                            |
|               {3} | 0 |                                            |
|               {3} | 1 |                                            |
|                                                                    |
|o6 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i7 : h = canonicalMap(C[-1], Cf)                                    |
|                                                                    |
|          1                   4                                     |
|o7 = 1 : S  <--------------- S  : 1                                 |
|               | 1 0 0 0 |                                          |
|                                                                    |
|          3                           6                             |
|     2 : S  <----------------------- S  : 2                         |
|               {2} | 1 0 0 0 0 0 |                                  |
|               {2} | 0 1 0 0 0 0 |                                  |
|               {2} | 0 0 1 0 0 0 |                                  |
|                                                                    |
|          2                     3                                   |
|     3 : S  <----------------- S  : 3                               |
|               {3} | 1 0 0 |                                        |
|               {3} | 0 1 0 |                                        |
|                                                                    |
|o7 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i8 : prune coker g == C[-1]                                         |
|                                                                    |
|o8 = true                                                           |
+--------------------------------------------------------------------+
|i9 : coker h == 0                                                   |
|                                                                    |
|o9 = true                                                           |
+--------------------------------------------------------------------+

There is a canonical map of complexes from the target to the cokernel.

+----------------------------------------------------------------+
|i10 : g1 = canonicalMap(coker g, target g)                      |
|                                                                |
|                                 1                              |
|o10 = 0 : cokernel | 1 | <----- S  : 0                          |
|                            0                                   |
|                                                                |
|                                                       4        |
|      1 : cokernel {0} | 0 0 0 | <------------------- S  : 1    |
|                   {1} | 1 0 0 |    {0} | 1 0 0 0 |             |
|                   {1} | 0 1 0 |    {1} | 0 0 0 0 |             |
|                   {1} | 0 0 1 |    {1} | 0 0 0 0 |             |
|                                    {1} | 0 0 0 0 |             |
|                                                                |
|                                                           6    |
|      2 : cokernel {2} | 0 0 0 | <----------------------- S  : 2|
|                   {2} | 0 0 0 |    {2} | 1 0 0 0 0 0 |         |
|                   {2} | 0 0 0 |    {2} | 0 1 0 0 0 0 |         |
|                   {2} | 1 0 0 |    {2} | 0 0 1 0 0 0 |         |
|                   {2} | 0 1 0 |    {2} | 0 0 0 0 0 0 |         |
|                   {2} | 0 0 1 |    {2} | 0 0 0 0 0 0 |         |
|                                    {2} | 0 0 0 0 0 0 |         |
|                                                                |
|                                                 3              |
|      3 : cokernel {3} | 0 | <----------------- S  : 3          |
|                   {3} | 0 |    {3} | 1 0 0 |                   |
|                   {3} | 1 |    {3} | 0 1 0 |                   |
|                                {3} | 0 0 0 |                   |
|                                                                |
|o10 : ComplexMap                                                |
+----------------------------------------------------------------+
|i11 : coker g == image g1                                       |
|                                                                |
|o11 = true                                                      |
+----------------------------------------------------------------+
|i12 : coker g1 == 0                                             |
|                                                                |
|o12 = true                                                      |
+----------------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * cokernel (Macaulay2Doc) -- cokernel of a map of modules,
    graded modules, or chaincomplexes
  * image(ComplexMap) -- make the image of a map
    of complexes
  * coimage(ComplexMap) -- make the coimage of
    a map of complexes
  * kernel(ComplexMap) -- make the kernel of a
    map of complexes
  * canonicalMap -- gets the natural map arising from
    various constructions

Ways to use this method:
========================

  * cokernel(ComplexMap) -- make the cokernel
    of a map of complexes

Complex -- the class of all chain complexes
*******************************************

Description
===========

A complex is a sequence of objects $C_i$, connected by maps $dd^C_i : C_i
\rightarrow C_{i-1}$ such that the composition of any two consecutive maps is
zero.

TODO: more needs to be added here explaining how to used complexes. and links
to "landing pages".

Functions and methods returning a complex :
===========================================

  * "canonicalTruncation(Complex,InfiniteNumber,InfiniteNumber)" -- see
    canonicalTruncation(Complex,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * "canonicalTruncation(Complex,InfiniteNumber,ZZ)" -- see
    canonicalTruncation(Complex,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * "canonicalTruncation(Complex,Nothing,ZZ)" -- see
    canonicalTruncation(Complex,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * "canonicalTruncation(Complex,Sequence)" -- see
    canonicalTruncation(Complex,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * "canonicalTruncation(Complex,ZZ,InfiniteNumber)" -- see
    canonicalTruncation(Complex,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * "canonicalTruncation(Complex,ZZ,Nothing)" -- see
    canonicalTruncation(Complex,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * canonicalTruncation(Complex,ZZ,ZZ)
    -- reducing the number of
    non-zero terms of a complex
  * coimage(ComplexMap) -- make the coimage of
    a map of complexes
  * cokernel(ComplexMap) -- make the cokernel
    of a map of complexes
  * "complex(List)" -- see complex, -- make a chain complex
  * Complex ** Complex -- tensor product of
    complexes
  * "Complex ** Module" -- see Complex ** Complex,
    -- tensor product of complexes
  * "Module ** Complex" -- see Complex ** Complex,
    -- tensor product of complexes
  * "tensor(Complex,Complex)" -- see Complex ** Complex,
    -- tensor product of complexes
  * complex(ChainComplex) -- translate
    between data types for chain complexes
  * complex(Complex) -- make a complex by
    reindexing the terms of the complex
  * complex(ComplexMap) -- make a complex by
    specifying the differential
  * complex(HashTable) -- make a chain complex
  * "complex(Ideal)" -- see complex(Module), -- make
    a chain complex of length zero
  * complex(Module) -- make a chain complex of
    length zero
  * "complex(Ring)" -- see complex(Module), -- make
    a chain complex of length zero
  * cone(ComplexMap) -- make the mapping cone of a
    morphism of chain complexes
  * "cylinder(ComplexMap)" -- see cylinder, -- make the mapping
    cylinder of a morphism of chain complexes
  * "Complex ++ Complex" -- see directSum(Complex),
    -- direct sum of complexes
  * dual(Complex) -- make the dual of a complex
  * "freeResolution(Ideal)" -- see freeResolution, --
    compute a free resolution of a module or ideal
  * "freeResolution(Module)" -- see freeResolution, --
    compute a free resolution of a module or ideal
  * "freeResolution(MonomialIdeal)" -- see freeResolution,
    -- compute a free resolution of a module or ideal
  * gradedModule(Complex) -- a new complex in
    which the differential is zero
  * HH Complex -- homology of a complex
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes
  * "Hom(Complex,Module)" -- see Hom(Complex,Complex),
    -- the complex of homomorphisms between two
    complexes
  * "Hom(Complex,Ring)" -- see Hom(Complex,Complex),
    -- the complex of homomorphisms between two
    complexes
  * "Hom(Module,Complex)" -- see Hom(Complex,Complex),
    -- the complex of homomorphisms between two
    complexes
  * "Hom(Ring,Complex)" -- see Hom(Complex,Complex),
    -- the complex of homomorphisms between two
    complexes
  * image(ComplexMap) -- make the image of a map
    of complexes
  * kernel(ComplexMap) -- make the kernel of a
    map of complexes
  * "koszulComplex(List)" -- see koszulComplex(Matrix),
    -- makes the Koszul complex
  * koszulComplex(Matrix) -- makes the Koszul
    complex
  * longExactSequence(ComplexMap,ComplexMap)
    -- make the long exact
    sequence in homology
  * minimalPresentation(Complex), --
    minimal presentation of all terms in a complex
  * "prune(Complex)" -- see minimalPresentation(Complex),
    -- minimal presentation of all terms in a
    complex
  * "naiveTruncation(Complex,InfiniteNumber,InfiniteNumber)" -- see
    naiveTruncation(Complex,ZZ,ZZ), --
    drops all terms of a complex outside a given interval
  * "naiveTruncation(Complex,InfiniteNumber,ZZ)" -- see
    naiveTruncation(Complex,ZZ,ZZ), --
    drops all terms of a complex outside a given interval
  * "naiveTruncation(Complex,Nothing,ZZ)" -- see
    naiveTruncation(Complex,ZZ,ZZ), --
    drops all terms of a complex outside a given interval
  * "naiveTruncation(Complex,Sequence)" -- see
    naiveTruncation(Complex,ZZ,ZZ), --
    drops all terms of a complex outside a given interval
  * "naiveTruncation(Complex,ZZ,InfiniteNumber)" -- see
    naiveTruncation(Complex,ZZ,ZZ), --
    drops all terms of a complex outside a given interval
  * "naiveTruncation(Complex,ZZ,Nothing)" -- see
    naiveTruncation(Complex,ZZ,ZZ), --
    drops all terms of a complex outside a given interval
  * naiveTruncation(Complex,ZZ,ZZ)
    -- drops all terms of a complex
    outside a given interval
  * part(List,Complex) -- extract a graded
    component of a complex
  * "part(ZZ,Complex)" -- see part(List,Complex),
    -- extract a graded component of a complex
  * "ring(ComplexMap)" -- see ring(Complex), -- access
    the ring of a complex or a complex map
  * "Complex ** Ring" -- see RingMap ** Complex,
    -- tensor a complex along a ring map
  * "Complex ** RingMap" -- see RingMap ** Complex,
    -- tensor a complex along a ring map
  * "Ring ** Complex" -- see RingMap ** Complex,
    -- tensor a complex along a ring map
  * RingMap ** Complex -- tensor a complex along
    a ring map
  * "tensor(Complex,RingMap)" -- see RingMap ** Complex,
    -- tensor a complex along a ring map
  * "tensor(RingMap,Complex)" -- see RingMap ** Complex,
    -- tensor a complex along a ring map
  * RingMap Complex -- apply a ring map
  * source(ComplexMap) -- get the source of a
    map of chain complexes
  * target(ComplexMap) -- get the target of a
    map of chain complexes
  * truncate(List,Complex) -- truncation
    of a complex at a specified degree or set of degrees
  * "truncate(ZZ,Complex)" -- see truncate(List,Complex),
    -- truncation of a complex at a specified
    degree or set of degrees
  * yonedaExtension(Matrix) -- creates a
    chain complex representing an extension of modules

Methods that use a complex :
============================

  * "augmentationMap(Complex)" -- see augmentationMap,
    -- map from a free resolution to a module regarded as a complex
  * betti(Complex) -- display of degrees in a
    complex
  * "canonicalMap(Complex,Complex)" -- see canonicalMap, --
    gets the natural map arising from various constructions
  * chainComplex(Complex) -- translate
    between data types for chain complexes
  * Complex ** Matrix -- create the tensor
    product of a complex and a map of modules
  * "Matrix ** Complex" -- see Complex ** Matrix,
    -- create the tensor product of a complex and a map of modules
  * Complex == Complex -- whether two complexes are
    equal
  * "Complex == ZZ" -- see Complex == Complex, --
    whether two complexes are equal
  * "ZZ == Complex" -- see Complex == Complex, --
    whether two complexes are equal
  * "Complex ^ Array" -- see Complex _ Array, -- the
    canonical inclusion or projection map of a direct sum
  * Complex _ Array -- the canonical inclusion or
    projection map of a direct sum
  * "Complex ^ ZZ" -- see Complex _ ZZ, -- access
    individual object in a complex
  * Complex _ ZZ -- access individual object in a
    complex
  * Complex Array -- shift a complex or complex map
  * "Complex ** ComplexMap" -- see ComplexMap ** ComplexMap,
    -- the map of complexes between tensor complexes
  * "ComplexMap ** Complex" -- see ComplexMap ** ComplexMap,
    -- the map of complexes between tensor complexes
  * components(Complex) -- list the components
    of a direct sum
  * "concentration(Complex)" -- see concentration, --
    indices on which a complex may be non-zero
  * "max(Complex)" -- see concentration, -- indices on
    which a complex may be non-zero
  * "min(Complex)" -- see concentration, -- indices on
    which a complex may be non-zero
  * "Symbol ^ Complex" -- see differential of a chain complex,
    -- get the maps between the terms in a
    complex
  * directSum(Complex) -- direct sum of
    complexes
  * "extend(Complex,Complex,Matrix)" -- see
    extend(Complex,Complex,Matrix,Sequence),
    -- extend a map of
    modules to a map of chain complexes
  * extend(Complex,Complex,Matrix,Sequence)
    -- extend a map of
    modules to a map of chain complexes
  * "HH^ZZ Complex" -- see HH_ZZ Complex, -- homology or
    cohomology module of a complex
  * HH_ZZ Complex -- homology or cohomology module of a
    complex
  * "Hom(Complex,ComplexMap)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(Complex,Matrix)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(ComplexMap,Complex)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(Matrix,Complex)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * homomorphism(ZZ,Matrix,Complex)
    -- get the homomorphism from an
    element of Hom
  * horseshoeResolution(Complex), --
    make the horseshoe resolution
  * inducedMap(Complex,Complex), --
    make the map of complexes induced at each term by the identity map
  * "isExact(Complex)" -- see isExact, -- whether a complex is
    exact
  * "isExact(Complex,InfiniteNumber,InfiniteNumber)" -- see isExact,
    -- whether a complex is exact
  * "isExact(Complex,InfiniteNumber,Number)" -- see isExact, --
    whether a complex is exact
  * "isExact(Complex,Number,InfiniteNumber)" -- see isExact, --
    whether a complex is exact
  * "isExact(Complex,Number,Number)" -- see isExact, -- whether
    a complex is exact
  * isFree(Complex) -- whether a complex consists
    of free modules
  * isHomogeneous(Complex) -- whether a
    complex is homogeneous
  * isShortExactSequence(Complex), --
    whether a chain complex is a short exact sequence
  * isWellDefined(Complex) -- whether a
    complex is well-defined
  * length(Complex) -- length of a complex
  * map(Complex,Complex,ComplexMap)
    -- make a new map of chain
    complexes from an existing one
  * map(Complex,Complex,Function),
    -- make a map of chain complexes
  * map(Complex,Complex,HashTable)
    -- make a map of chain complexes
  * map(Complex,Complex,List) -- make
    a map of chain complexes
  * map(Complex,Complex,ZZ) -- make the
    zero map or identity between chain complexes
  * minimize(Complex) -- a quasi-isomorphic
    complex whose terms have minimal rank
  * poincare(Complex) -- assemble degrees of a
    chain complex into a polynomial
  * poincareN(Complex) -- assemble degrees of a
    chain complex into a polynomial
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes
  * regularity(Complex) -- compute the
    Castelnuovo-Mumford regularity
  * resolution(Complex) -- minimal free
    resolution of a complex
  * "resolutionMap(Complex)" -- see resolutionMap, -- map
    from a free resolution to the given complex
  * ring(Complex) -- access the ring of a complex or
    a complex map
  * sum(Complex) -- make the direct sum of all terms
  * tensorAssociativity(Complex,Complex,Complex)
    -- make the canonical
    isomorphism arising from associativity
  * tensorCommutativity(Complex,Complex)
    -- make the canonical
    isomorphism arising from commutativity
  * yonedaExtension'(Complex), --
    identifies the element of Ext corresponding to an extension

For the programmer
==================

The object Complex, is a type (Macaulay2Doc), with
ancestor classes MutableHashTable (Macaulay2Doc), <
HashTable (Macaulay2Doc) < Thing (Macaulay2Doc).

complex -- make a chain complex
*******************************

Synopsis
========

  * Usage:
        complex L
  * Inputs:
      * L, a list (Macaulay2Doc), of maps
  * Optional inputs (Macaulay2Doc),:
      * Base => an integer (Macaulay2Doc), default value 0, the index
        of the target of the first map in the differential.
  * Outputs:
      * a complex,

Description
===========

A complex is a sequence of objects (e.g. modules), connected by maps called
differentials.  The composition of any two consecutive maps is zero.

The same data type is used for both chain and cochain complexes.  If C is a
complex, then we have C^i = C_{-i}.

Often, a complex is most easily described by giving a list of consecutive maps
which form the differential.

We construct the Koszul complex on the generators for the ideal of the twisted
cubic curve.

+-----------------------------------------------------+
|i1 : S = ZZ/101[a..d]                                |
|                                                     |
|o1 = S                                               |
|                                                     |
|o1 : PolynomialRing                                  |
+-----------------------------------------------------+
|i2 : I = ideal(b^2-a*c, b*c-a*d, c^2-b*d)            |
|                                                     |
|             2                    2                  |
|o2 = ideal (b  - a*c, b*c - a*d, c  - b*d)           |
|                                                     |
|o2 : Ideal of S                                      |
+-----------------------------------------------------+
|i3 : F1 = map(S^1,,matrix{{I_0, I_1, I_2}})          |
|                                                     |
|o3 = | b2-ac bc-ad c2-bd |                           |
|                                                     |
|             1       3                               |
|o3 : Matrix S  <--- S                                |
+-----------------------------------------------------+
|i4 : F2 = map(source F1,,matrix{                     |
|             {0, I_2, -I_1},                         |
|             {-I_2, 0, I_0},                         |
|             {I_1, -I_0, 0}                          |
|             })                                      |
|                                                     |
|o4 = {2} | 0      c2-bd  -bc+ad |                    |
|     {2} | -c2+bd 0      b2-ac  |                    |
|     {2} | bc-ad  -b2+ac 0      |                    |
|                                                     |
|             3       3                               |
|o4 : Matrix S  <--- S                                |
+-----------------------------------------------------+
|i5 : F3 = map(source F2,,matrix{{I_0}, {I_1}, {I_2}})|
|                                                     |
|o5 = {4} | b2-ac |                                   |
|     {4} | bc-ad |                                   |
|     {4} | c2-bd |                                   |
|                                                     |
|             3       1                               |
|o5 : Matrix S  <--- S                                |
+-----------------------------------------------------+
|i6 : C = complex {F1, F2, F3}                        |
|                                                     |
|      1      3      3      1                         |
|o6 = S  <-- S  <-- S  <-- S                          |
|                                                     |
|     0      1      2      3                          |
|                                                     |
|o6 : Complex                                         |
+-----------------------------------------------------+
|i7 : isWellDefined C                                 |
|                                                     |
|o7 = true                                            |
+-----------------------------------------------------+

To start a complex at a base different from zero, use the optional argument
Base.

+------------------------------------------+
|i8 : C1 = complex({F1, F2, F3}, Base => 1)|
|                                          |
|      1      3      3      1              |
|o8 = S  <-- S  <-- S  <-- S               |
|                                          |
|     1      2      3      4               |
|                                          |
|o8 : Complex                              |
+------------------------------------------+
|i9 : isWellDefined C1                     |
|                                          |
|o9 = true                                 |
+------------------------------------------+

Notice that this changes the homological degrees of the maps, but is not the
same as the shift of the complex (which for odd shifts negates the maps).

+-----------------------------------------------------+
|i10 : dd^C1                                          |
|                                                     |
|           1                             3           |
|o10 = 1 : S  <------------------------- S  : 2       |
|                | b2-ac bc-ad c2-bd |                |
|                                                     |
|           3                                    3    |
|      2 : S  <-------------------------------- S  : 3|
|                {2} | 0      c2-bd  -bc+ad |         |
|                {2} | -c2+bd 0      b2-ac  |         |
|                {2} | bc-ad  -b2+ac 0      |         |
|                                                     |
|           3                     1                   |
|      3 : S  <----------------- S  : 4               |
|                {4} | b2-ac |                        |
|                {4} | bc-ad |                        |
|                {4} | c2-bd |                        |
|                                                     |
|o10 : ComplexMap                                     |
+-----------------------------------------------------+
|i11 : dd^(C[-1])                                     |
|                                                     |
|           1                                3        |
|o11 = 1 : S  <---------------------------- S  : 2    |
|                | -b2+ac -bc+ad -c2+bd |             |
|                                                     |
|           3                                    3    |
|      2 : S  <-------------------------------- S  : 3|
|                {2} | 0      -c2+bd bc-ad  |         |
|                {2} | c2-bd  0      -b2+ac |         |
|                {2} | -bc+ad b2-ac  0      |         |
|                                                     |
|           3                      1                  |
|      3 : S  <------------------ S  : 4              |
|                {4} | -b2+ac |                       |
|                {4} | -bc+ad |                       |
|                {4} | -c2+bd |                       |
|                                                     |
|o11 : ComplexMap                                     |
+-----------------------------------------------------+

Having constructed this complex, we can access individual terms and maps.

+-----------------------------------------------------+
|i12 : C_2                                            |
|                                                     |
|       3                                             |
|o12 = S                                              |
|                                                     |
|o12 : S-module, free, degrees {3:4}                  |
+-----------------------------------------------------+
|i13 : C^(-1)                                         |
|                                                     |
|       3                                             |
|o13 = S                                              |
|                                                     |
|o13 : S-module, free, degrees {3:2}                  |
+-----------------------------------------------------+
|i14 : C^(-1) == C_1                                  |
|                                                     |
|o14 = true                                           |
+-----------------------------------------------------+
|i15 : C_7                                            |
|                                                     |
|o15 = 0                                              |
|                                                     |
|o15 : S-module                                       |
+-----------------------------------------------------+
|i16 : dd^C                                           |
|                                                     |
|           1                             3           |
|o16 = 0 : S  <------------------------- S  : 1       |
|                | b2-ac bc-ad c2-bd |                |
|                                                     |
|           3                                    3    |
|      1 : S  <-------------------------------- S  : 2|
|                {2} | 0      c2-bd  -bc+ad |         |
|                {2} | -c2+bd 0      b2-ac  |         |
|                {2} | bc-ad  -b2+ac 0      |         |
|                                                     |
|           3                     1                   |
|      2 : S  <----------------- S  : 3               |
|                {4} | b2-ac |                        |
|                {4} | bc-ad |                        |
|                {4} | c2-bd |                        |
|                                                     |
|o16 : ComplexMap                                     |
+-----------------------------------------------------+
|i17 : dd^C_2                                         |
|                                                     |
|o17 = {2} | 0      c2-bd  -bc+ad |                   |
|      {2} | -c2+bd 0      b2-ac  |                   |
|      {2} | bc-ad  -b2+ac 0      |                   |
|                                                     |
|              3       3                              |
|o17 : Matrix S  <--- S                               |
+-----------------------------------------------------+
|i18 : length C                                       |
|                                                     |
|o18 = 3                                              |
+-----------------------------------------------------+

By computing the homology of this complex, we see that these generators do not
form a regular sequence, because $H_1(C)$ is non-zero.

+-----------------------------------------------------------------------------+
|i19 : HH C                                                                   |
|                                                                             |
|o19 = cokernel | b2-ac bc-ad c2-bd | <-- subquotient ({2} | d  c  |, {2} |   |
|                                                      {2} | -c -b |  {2} |   |
|      0                                               {2} | b  a  |  {2} |   |
|                                                                             |
|                                         1                                   |
|                                                                             |
|o19 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0      c2-bd  -bc+ad |) <-- subquotient ({4} | b2-ac |, {4} | b2-ac |) <--   |
|-c2+bd 0      b2-ac  |                   {4} | bc-ad |  {4} | bc-ad |        |
|bc-ad  -b2+ac 0      |                   {4} | c2-bd |  {4} | c2-bd |        |
|                                                                             |
|                            2                                                |
|-----------------------------------------------------------------------------|
|image 0                                                                      |
|                                                                             |
|3                                                                            |
+-----------------------------------------------------------------------------+
|i20 : prune HH C                                                             |
|                                                                             |
|o20 = cokernel | c2-bd bc-ad b2-ac | <-- cokernel {3} | c  b  a  |           |
|                                                  {3} | -d -c -b |           |
|      0                                                                      |
|                                         1                                   |
|                                                                             |
|o20 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i21 : prune HH_1 C                                                           |
|                                                                             |
|o21 = cokernel {3} | c  b  a  |                                              |
|               {3} | -d -c -b |                                              |
|                                                                             |
|                             2                                               |
|o21 : S-module, quotient of S                                                |
+-----------------------------------------------------------------------------+

Caveat
======

This constructor minimizes computation and does very little error checking. To
verify that a complex is well constructed, use isWellDefined(Complex).

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * isWellDefined(Complex) -- whether a
    complex is well-defined
  * complex(HashTable) -- make a chain complex
  * complex(Module) -- make a chain complex of
    length zero
  * Complex Array -- shift a complex or complex map

Ways to use complex :
=====================

  * "complex(List)"
  * complex(ChainComplex) -- translate
    between data types for chain complexes
  * complex(ChainComplexMap) -- translate
    between data types for chain complex maps
  * complex(Complex) -- make a complex by
    reindexing the terms of the complex
  * complex(ComplexMap) -- make a complex by
    specifying the differential
  * complex(HashTable) -- make a chain complex
  * "complex(Ideal)" -- see complex(Module), -- make
    a chain complex of length zero
  * complex(Module) -- make a chain complex of
    length zero
  * "complex(Ring)" -- see complex(Module), -- make
    a chain complex of length zero

For the programmer
==================

The object complex, is a method function with options (Macaulay2Doc).

Complex ** Complex -- tensor product of complexes
*************************************************

Synopsis
========

  * Operator: ** (Macaulay2Doc),
  * Usage:
        D = C1 ** C2
  * Inputs:
      * C1, a complex, or a module (Macaulay2Doc),
      * C2, a complex, or a module (Macaulay2Doc),
  * Outputs:
      * D, a complex, tensor product of C1 and C2

Description
===========

The tensor product is a complex $D$ whose $i$th component is the direct sum of
$C1_j \otimes C2_k$ over all $i = j+k$. The differential on $C1_j \otimes C2_k$
is the differential $dd^{C1} \otimes id_{C2} + (-1)^j id_{C1} \otimes dd^{C2}$.

As the next example illustrates, the Koszul complex can be constructed via
iterated tensor products.

+-----------------------------------------+
|i1 : S = ZZ/101[a..c]                    |
|                                         |
|o1 = S                                   |
|                                         |
|o1 : PolynomialRing                      |
+-----------------------------------------+
|i2 : Ca = complex {matrix{{a}}}          |
|                                         |
|      1      1                           |
|o2 = S  <-- S                            |
|                                         |
|     0      1                            |
|                                         |
|o2 : Complex                             |
+-----------------------------------------+
|i3 : Cb = complex {matrix{{b}}}          |
|                                         |
|      1      1                           |
|o3 = S  <-- S                            |
|                                         |
|     0      1                            |
|                                         |
|o3 : Complex                             |
+-----------------------------------------+
|i4 : Cc = complex {matrix{{c}}}          |
|                                         |
|      1      1                           |
|o4 = S  <-- S                            |
|                                         |
|     0      1                            |
|                                         |
|o4 : Complex                             |
+-----------------------------------------+
|i5 : Cab = Cb ** Ca                      |
|                                         |
|      1      2      1                    |
|o5 = S  <-- S  <-- S                     |
|                                         |
|     0      1      2                     |
|                                         |
|o5 : Complex                             |
+-----------------------------------------+
|i6 : dd^Cab                              |
|                                         |
|          1               2              |
|o6 = 0 : S  <----------- S  : 1          |
|               | a b |                   |
|                                         |
|          2                  1           |
|     1 : S  <-------------- S  : 2       |
|               {1} | b  |                |
|               {1} | -a |                |
|                                         |
|o6 : ComplexMap                          |
+-----------------------------------------+
|i7 : assert isWellDefined Cab            |
+-----------------------------------------+
|i8 : Cabc = Cc ** Cab                    |
|                                         |
|      1      3      3      1             |
|o8 = S  <-- S  <-- S  <-- S              |
|                                         |
|     0      1      2      3              |
|                                         |
|o8 : Complex                             |
+-----------------------------------------+
|i9 : Cc ** Cb ** Ca                      |
|                                         |
|      1      3      3      1             |
|o9 = S  <-- S  <-- S  <-- S              |
|                                         |
|     0      1      2      3              |
|                                         |
|o9 : Complex                             |
+-----------------------------------------+
|i10 : dd^Cabc                            |
|                                         |
|           1                 3           |
|o10 = 0 : S  <------------- S  : 1       |
|                | a b c |                |
|                                         |
|           3                        3    |
|      1 : S  <-------------------- S  : 2|
|                {1} | b  c  0  |         |
|                {1} | -a 0  c  |         |
|                {1} | 0  -a -b |         |
|                                         |
|           3                  1          |
|      2 : S  <-------------- S  : 3      |
|                {2} | c  |               |
|                {2} | -b |               |
|                {2} | a  |               |
|                                         |
|o10 : ComplexMap                         |
+-----------------------------------------+
|i11 : assert isWellDefined Cabc          |
+-----------------------------------------+

If one of the arguments is a module, it is considered as a complex concentrated
in homological degree 0.

+-----------------------------------------------------------------------------+
|i12 : Cabc ** (S^1/(a,b,c))                                                  |
|                                                                             |
|o12 = cokernel | a b c | <-- cokernel {1} | a b c 0 0 0 0 0 0 | <-- cokernel |
|                                      {1} | 0 0 0 a b c 0 0 0 |              |
|      0                               {1} | 0 0 0 0 0 0 a b c |              |
|                                                                             |
|                             1                                      2        |
|                                                                             |
|o12 : Complex                                                                |
|-----------------------------------------------------------------------------|
|{2} | a b c 0 0 0 0 0 0 | <-- cokernel {3} | a b c |                         |
|{2} | 0 0 0 a b c 0 0 0 |                                                    |
|{2} | 0 0 0 0 0 0 a b c |     3                                              |
+-----------------------------------------------------------------------------+
|i13 : S^2 ** Cabc                                                            |
|                                                                             |
|       2      6      6      2                                                |
|o13 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o13 : Complex                                                                |
+-----------------------------------------------------------------------------+

Because the tensor product can be regarded as the total complex of a double
complex, each term of the tensor product comes with pairs of indices, labelling
the summands.

+-----------------------+
|i14 : indices Cabc_1   |
|                       |
|o14 = {{0, 1}, {1, 0}} |
|                       |
|o14 : List             |
+-----------------------+
|i15 : components Cabc_1|
|                       |
|        2   1          |
|o15 = {S , S }         |
|                       |
|o15 : List             |
+-----------------------+
|i16 : Cabc_1_[{1,0}]   |
|                       |
|o16 = {1} | 0 |        |
|      {1} | 0 |        |
|      {1} | 1 |        |
|                       |
|              3       1|
|o16 : Matrix S  <--- S |
+-----------------------+
|i17 : indices Cabc_2   |
|                       |
|o17 = {{0, 2}, {1, 1}} |
|                       |
|o17 : List             |
+-----------------------+
|i18 : components Cabc_2|
|                       |
|        1   2          |
|o18 = {S , S }         |
|                       |
|o18 : List             |
+-----------------------+
|i19 : Cabc_2_[{0,2}]   |
|                       |
|o19 = {2} | 1 |        |
|      {2} | 0 |        |
|      {2} | 0 |        |
|                       |
|              3       1|
|o19 : Matrix S  <--- S |
+-----------------------+

See also
========

  * indices (Macaulay2Doc) -- indices of a polynomial; also
    components for a direct sum
  * components (Macaulay2Doc) -- list the components of a
    direct sum
  * directSum (Macaulay2Doc) -- direct sum of modules or maps

Ways to use this method:
========================

  * Complex ** Complex -- tensor product of
    complexes
  * "Complex ** Module"
  * "Module ** Complex"

Complex ** Matrix -- create the tensor product of a complex and a map of modules
********************************************************************************

Synopsis
========

  * Operator: ** (Macaulay2Doc),
  * Usage:
        h = C ** f
        h = f ** C
  * Inputs:
      * C, a complex, over a ring $R$
      * f, a matrix (Macaulay2Doc), defining a homomorphism from
        the $R$-module $M$ to the $R$-module $N$
  * Outputs:
      * h, a map of complexes, from $C \otimes M$ to $C
        \otimes N$

Description
===========

For any chain complex $C$, a map $f \colon M \to N$ of $R$-modules induces a
morphism $C \otimes f$ of chain complexes from $C \otimes M$ to $C \otimes N$.
This method returns this map of chain complexes.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a..d];                                                       |
+-----------------------------------------------------------------------------+
|i2 : I = ideal(c^2-b*d, b*c-a*d, b^2-a*c)                                    |
|                                                                             |
|             2                    2                                          |
|o2 = ideal (c  - b*d, b*c - a*d, b  - a*c)                                   |
|                                                                             |
|o2 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i3 : J = ideal(I_0, I_1)                                                     |
|                                                                             |
|             2                                                               |
|o3 = ideal (c  - b*d, b*c - a*d)                                             |
|                                                                             |
|o3 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i4 : C = koszulComplex vars R                                                |
|                                                                             |
|      1      4      6      4      1                                          |
|o4 = R  <-- R  <-- R  <-- R  <-- R                                           |
|                                                                             |
|     0      1      2      3      4                                           |
|                                                                             |
|o4 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i5 : f = map(R^1/I, R^1/J, 1)                                                |
|                                                                             |
|o5 = | 1 |                                                                   |
|                                                                             |
|o5 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i6 : C ** f                                                                  |
|                                                                             |
|o6 = 0 : cokernel | c2-bd bc-ad b2-ac | <--------- cokernel | c2-bd bc-ad | :|
|                                           | 1 |                             |
|                                                                             |
|     1 : cokernel {1} | c2-bd bc-ad b2-ac 0     0     0     0     0     0    |
|                  {1} | 0     0     0     c2-bd bc-ad b2-ac 0     0     0    |
|                  {1} | 0     0     0     0     0     0     c2-bd bc-ad b2-ac|
|                  {1} | 0     0     0     0     0     0     0     0     0    |
|                                                                             |
|                                                                             |
|     2 : cokernel {2} | c2-bd bc-ad b2-ac 0     0     0     0     0     0    |
|                  {2} | 0     0     0     c2-bd bc-ad b2-ac 0     0     0    |
|                  {2} | 0     0     0     0     0     0     c2-bd bc-ad b2-ac|
|                  {2} | 0     0     0     0     0     0     0     0     0    |
|                  {2} | 0     0     0     0     0     0     0     0     0    |
|                  {2} | 0     0     0     0     0     0     0     0     0    |
|                                                                             |
|                                                                             |
|     3 : cokernel {3} | c2-bd bc-ad b2-ac 0     0     0     0     0     0    |
|                  {3} | 0     0     0     c2-bd bc-ad b2-ac 0     0     0    |
|                  {3} | 0     0     0     0     0     0     c2-bd bc-ad b2-ac|
|                  {3} | 0     0     0     0     0     0     0     0     0    |
|                                                                             |
|                                                                             |
|     4 : cokernel {4} | c2-bd bc-ad b2-ac | <------------- cokernel {4} | c2-|
|                                               {4} | 1 |                     |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
| 0                                                                           |
|                                                                             |
|                                                                             |
| 0     0     0     | <------------------- cokernel {1} |                     |
| 0     0     0     |    {1} | 1 0 0 0 |            {1} |                     |
| 0     0     0     |    {1} | 0 1 0 0 |            {1} |                     |
| c2-bd bc-ad b2-ac |    {1} | 0 0 1 0 |            {1} |                     |
|                        {1} | 0 0 0 1 |                                      |
|                                                                             |
| 0     0     0     0     0     0     0     0     0     |                     |
| 0     0     0     0     0     0     0     0     0     |                     |
| 0     0     0     0     0     0     0     0     0     |                     |
| c2-bd bc-ad b2-ac 0     0     0     0     0     0     |                     |
| 0     0     0     c2-bd bc-ad b2-ac 0     0     0     |                     |
| 0     0     0     0     0     0     c2-bd bc-ad b2-ac |                     |
|                                                                             |
|                                                                             |
| 0     0     0     | <------------------- cokernel {3} |                     |
| 0     0     0     |    {3} | 1 0 0 0 |            {3} |                     |
| 0     0     0     |    {3} | 0 1 0 0 |            {3} |                     |
| c2-bd bc-ad b2-ac |    {3} | 0 0 1 0 |            {3} |                     |
|                        {3} | 0 0 0 1 |                                      |
|                                                                             |
|bd bc-ad | : 4                                                               |
|-----------------------------------------------------------------------------|
|c2-bd bc-ad 0     0     0     0     0     0     | : 1                        |
|0     0     c2-bd bc-ad 0     0     0     0     |                            |
|0     0     0     0     c2-bd bc-ad 0     0     |                            |
|0     0     0     0     0     0     c2-bd bc-ad |                            |
|                                                                             |
|                                                                             |
|<----------------------- cokernel {2} | c2-bd bc-ad 0     0     0     0      |
|   {2} | 1 0 0 0 0 0 |            {2} | 0     0     c2-bd bc-ad 0     0      |
|   {2} | 0 1 0 0 0 0 |            {2} | 0     0     0     0     c2-bd bc-ad  |
|   {2} | 0 0 1 0 0 0 |            {2} | 0     0     0     0     0     0      |
|   {2} | 0 0 0 1 0 0 |            {2} | 0     0     0     0     0     0      |
|   {2} | 0 0 0 0 1 0 |            {2} | 0     0     0     0     0     0      |
|   {2} | 0 0 0 0 0 1 |                                                       |
|                                                                             |
|c2-bd bc-ad 0     0     0     0     0     0     | : 3                        |
|0     0     c2-bd bc-ad 0     0     0     0     |                            |
|0     0     0     0     c2-bd bc-ad 0     0     |                            |
|0     0     0     0     0     0     c2-bd bc-ad |                            |
|-----------------------------------------------------------------------------|
|0     0     0     0     0     0     | : 2                                    |
|0     0     0     0     0     0     |                                        |
|0     0     0     0     0     0     |                                        |
|c2-bd bc-ad 0     0     0     0     |                                        |
|0     0     c2-bd bc-ad 0     0     |                                        |
|0     0     0     0     c2-bd bc-ad |                                        |
+-----------------------------------------------------------------------------+
|i7 : f ** C                                                                  |
|                                                                             |
|o7 = 0 : cokernel | c2-bd bc-ad b2-ac | <--------- cokernel | c2-bd bc-ad | :|
|                                           | 1 |                             |
|                                                                             |
|     1 : cokernel {1} | c2-bd 0     0     0     bc-ad 0     0     0     b2-ac|
|                  {1} | 0     c2-bd 0     0     0     bc-ad 0     0     0    |
|                  {1} | 0     0     c2-bd 0     0     0     bc-ad 0     0    |
|                  {1} | 0     0     0     c2-bd 0     0     0     bc-ad 0    |
|                                                                             |
|                                                                             |
|     2 : cokernel {2} | c2-bd 0     0     0     0     0     bc-ad 0     0    |
|                  {2} | 0     c2-bd 0     0     0     0     0     bc-ad 0    |
|                  {2} | 0     0     c2-bd 0     0     0     0     0     bc-ad|
|                  {2} | 0     0     0     c2-bd 0     0     0     0     0    |
|                  {2} | 0     0     0     0     c2-bd 0     0     0     0    |
|                  {2} | 0     0     0     0     0     c2-bd 0     0     0    |
|                                                                             |
|                                                                             |
|     3 : cokernel {3} | c2-bd 0     0     0     bc-ad 0     0     0     b2-ac|
|                  {3} | 0     c2-bd 0     0     0     bc-ad 0     0     0    |
|                  {3} | 0     0     c2-bd 0     0     0     bc-ad 0     0    |
|                  {3} | 0     0     0     c2-bd 0     0     0     bc-ad 0    |
|                                                                             |
|                                                                             |
|     4 : cokernel {4} | c2-bd bc-ad b2-ac | <------------- cokernel {4} | c2-|
|                                               {4} | 1 |                     |
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
| 0                                                                           |
|                                                                             |
|                                                                             |
| 0     0     0     | <------------------- cokernel {1} |                     |
| b2-ac 0     0     |    {1} | 1 0 0 0 |            {1} |                     |
| 0     b2-ac 0     |    {1} | 0 1 0 0 |            {1} |                     |
| 0     0     b2-ac |    {1} | 0 0 1 0 |            {1} |                     |
|                        {1} | 0 0 0 1 |                                      |
|                                                                             |
| 0     0     0     b2-ac 0     0     0     0     0     |                     |
| 0     0     0     0     b2-ac 0     0     0     0     |                     |
| 0     0     0     0     0     b2-ac 0     0     0     |                     |
| bc-ad 0     0     0     0     0     b2-ac 0     0     |                     |
| 0     bc-ad 0     0     0     0     0     b2-ac 0     |                     |
| 0     0     bc-ad 0     0     0     0     0     b2-ac |                     |
|                                                                             |
|                                                                             |
| 0     0     0     | <------------------- cokernel {3} |                     |
| b2-ac 0     0     |    {3} | 1 0 0 0 |            {3} |                     |
| 0     b2-ac 0     |    {3} | 0 1 0 0 |            {3} |                     |
| 0     0     b2-ac |    {3} | 0 0 1 0 |            {3} |                     |
|                        {3} | 0 0 0 1 |                                      |
|                                                                             |
|bd bc-ad | : 4                                                               |
|-----------------------------------------------------------------------------|
|c2-bd 0     0     0     bc-ad 0     0     0     | : 1                        |
|0     c2-bd 0     0     0     bc-ad 0     0     |                            |
|0     0     c2-bd 0     0     0     bc-ad 0     |                            |
|0     0     0     c2-bd 0     0     0     bc-ad |                            |
|                                                                             |
|                                                                             |
|<----------------------- cokernel {2} | c2-bd 0     0     0     0     0      |
|   {2} | 1 0 0 0 0 0 |            {2} | 0     c2-bd 0     0     0     0      |
|   {2} | 0 1 0 0 0 0 |            {2} | 0     0     c2-bd 0     0     0      |
|   {2} | 0 0 1 0 0 0 |            {2} | 0     0     0     c2-bd 0     0      |
|   {2} | 0 0 0 1 0 0 |            {2} | 0     0     0     0     c2-bd 0      |
|   {2} | 0 0 0 0 1 0 |            {2} | 0     0     0     0     0     c2-bd  |
|   {2} | 0 0 0 0 0 1 |                                                       |
|                                                                             |
|c2-bd 0     0     0     bc-ad 0     0     0     | : 3                        |
|0     c2-bd 0     0     0     bc-ad 0     0     |                            |
|0     0     c2-bd 0     0     0     bc-ad 0     |                            |
|0     0     0     c2-bd 0     0     0     bc-ad |                            |
|-----------------------------------------------------------------------------|
|bc-ad 0     0     0     0     0     | : 2                                    |
|0     bc-ad 0     0     0     0     |                                        |
|0     0     bc-ad 0     0     0     |                                        |
|0     0     0     bc-ad 0     0     |                                        |
|0     0     0     0     bc-ad 0     |                                        |
|0     0     0     0     0     bc-ad |                                        |
+-----------------------------------------------------------------------------+
|i8 : f' = random(R^2, R^{-1, -1, -1})                                        |
|                                                                             |
|o8 = | 24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  |                   |
|     | 19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d |                   |
|                                                                             |
|             2       3                                                       |
|o8 : Matrix R  <--- R                                                        |
+-----------------------------------------------------------------------------+
|i9 : C ** f'                                                                 |
|                                                                             |
|          2                                                             3    |
|o9 = 0 : R  <--------------------------------------------------------- R  : 0|
|               | 24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  |         |
|               | 19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d |         |
|                                                                             |
|          8                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {1} | 24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  0     |
|               {1} | 19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d 0     |
|               {1} | 0               0                0                24a-36|
|               {1} | 0               0                0                19a+19|
|               {1} | 0               0                0                0     |
|               {1} | 0               0                0                0     |
|               {1} | 0               0                0                0     |
|               {1} | 0               0                0                0     |
|                                                                             |
|          12                                                                 |
|     2 : R   <---------------------------------------------------------------|
|                {2} | 24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  0    |
|                {2} | 19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d 0    |
|                {2} | 0               0                0                24a-3|
|                {2} | 0               0                0                19a+1|
|                {2} | 0               0                0                0    |
|                {2} | 0               0                0                0    |
|                {2} | 0               0                0                0    |
|                {2} | 0               0                0                0    |
|                {2} | 0               0                0                0    |
|                {2} | 0               0                0                0    |
|                {2} | 0               0                0                0    |
|                {2} | 0               0                0                0    |
|                                                                             |
|          8                                                                  |
|     3 : R  <----------------------------------------------------------------|
|               {3} | 24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  0     |
|               {3} | 19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d 0     |
|               {3} | 0               0                0                24a-36|
|               {3} | 0               0                0                19a+19|
|               {3} | 0               0                0                0     |
|               {3} | 0               0                0                0     |
|               {3} | 0               0                0                0     |
|               {3} | 0               0                0                0     |
|                                                                             |
|          2                                                                 3|
|     4 : R  <------------------------------------------------------------- R |
|               {4} | 24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  |     |
|               {4} | 19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d |     |
|                                                                             |
|o9 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|          0                0                0               0                |
|          0                0                0               0                |
|b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  0               0                |
|b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d 0               0                |
|          0                0                24a-36b-30c-29d -8a-22b-29c-24d  |
|          0                0                19a+19b-10c-29d -38a-16b+39c+21d |
|          0                0                0               0                |
|          0                0                0               0                |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|           0                0                0               0               |
|           0                0                0               0               |
|6b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  0               0               |
|9b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d 0               0               |
|           0                0                24a-36b-30c-29d -8a-22b-29c-24d |
|           0                0                19a+19b-10c-29d -38a-16b+39c+21d|
|           0                0                0               0               |
|           0                0                0               0               |
|           0                0                0               0               |
|           0                0                0               0               |
|           0                0                0               0               |
|           0                0                0               0               |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|          0                0                0               0                |
|          0                0                0               0                |
|b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  0               0                |
|b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d 0               0                |
|          0                0                24a-36b-30c-29d -8a-22b-29c-24d  |
|          0                0                19a+19b-10c-29d -38a-16b+39c+21d |
|          0                0                0               0                |
|          0                0                0               0                |
|                                                                             |
|                                                                             |
| : 4                                                                         |
|-----------------------------------------------------------------------------|
|                                                                        12   |
|---------------------------------------------------------------------- R   : |
|0                0               0                0                |         |
|0                0               0                0                |         |
|0                0               0                0                |         |
|0                0               0                0                |         |
|34a+19b-47c-39d  0               0                0                |         |
|-18a-13b-43c-15d 0               0                0                |         |
|0                24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  |         |
|0                19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d |         |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
| 0                0               0                0                0        |
| 0                0               0                0                0        |
| 0                0               0                0                0        |
| 0                0               0                0                0        |
| 34a+19b-47c-39d  0               0                0                0        |
| -18a-13b-43c-15d 0               0                0                0        |
| 0                24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  0        |
| 0                19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d 0        |
| 0                0               0                0                24a-36b-3|
| 0                0               0                0                19a+19b-1|
| 0                0               0                0                0        |
| 0                0               0                0                0        |
|                                                                             |
|                                                                        12   |
|---------------------------------------------------------------------- R   : |
|0                0               0                0                |         |
|0                0               0                0                |         |
|0                0               0                0                |         |
|0                0               0                0                |         |
|34a+19b-47c-39d  0               0                0                |         |
|-18a-13b-43c-15d 0               0                0                |         |
|0                24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  |         |
|0                19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d |         |
|-----------------------------------------------------------------------------|
|1                                                                            |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|       0                0                0               0                0  |
|       0                0                0               0                0  |
|       0                0                0               0                0  |
|       0                0                0               0                0  |
|       0                0                0               0                0  |
|       0                0                0               0                0  |
|       0                0                0               0                0  |
|       0                0                0               0                0  |
|0c-29d -8a-22b-29c-24d  34a+19b-47c-39d  0               0                0  |
|0c-29d -38a-16b+39c+21d -18a-13b-43c-15d 0               0                0  |
|       0                0                24a-36b-30c-29d -8a-22b-29c-24d  34a|
|       0                0                19a+19b-10c-29d -38a-16b+39c+21d -18|
|                                                                             |
|                                                                             |
|3                                                                            |
|-----------------------------------------------------------------------------|
|                   18                                                        |
|----------------- R   : 2                                                    |
|              |                                                              |
|              |                                                              |
|              |                                                              |
|              |                                                              |
|              |                                                              |
|              |                                                              |
|              |                                                              |
|              |                                                              |
|              |                                                              |
|              |                                                              |
|+19b-47c-39d  |                                                              |
|a-13b-43c-15d |                                                              |
+-----------------------------------------------------------------------------+
|i10 : f' ** C                                                                |
|                                                                             |
|           2                                                             3   |
|o10 = 0 : R  <--------------------------------------------------------- R  : |
|                | 24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  |        |
|                | 19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d |        |
|                                                                             |
|           8                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {1} | 24a-36b-30c-29d 0               0               0      |
|                {1} | 0               24a-36b-30c-29d 0               0      |
|                {1} | 0               0               24a-36b-30c-29d 0      |
|                {1} | 0               0               0               24a-36b|
|                {1} | 19a+19b-10c-29d 0               0               0      |
|                {1} | 0               19a+19b-10c-29d 0               0      |
|                {1} | 0               0               19a+19b-10c-29d 0      |
|                {1} | 0               0               0               19a+19b|
|                                                                             |
|           12                                                                |
|      2 : R   <--------------------------------------------------------------|
|                 {2} | 24a-36b-30c-29d 0               0               0     |
|                 {2} | 0               24a-36b-30c-29d 0               0     |
|                 {2} | 0               0               24a-36b-30c-29d 0     |
|                 {2} | 0               0               0               24a-36|
|                 {2} | 0               0               0               0     |
|                 {2} | 0               0               0               0     |
|                 {2} | 19a+19b-10c-29d 0               0               0     |
|                 {2} | 0               19a+19b-10c-29d 0               0     |
|                 {2} | 0               0               19a+19b-10c-29d 0     |
|                 {2} | 0               0               0               19a+19|
|                 {2} | 0               0               0               0     |
|                 {2} | 0               0               0               0     |
|                                                                             |
|           8                                                                 |
|      3 : R  <---------------------------------------------------------------|
|                {3} | 24a-36b-30c-29d 0               0               0      |
|                {3} | 0               24a-36b-30c-29d 0               0      |
|                {3} | 0               0               24a-36b-30c-29d 0      |
|                {3} | 0               0               0               24a-36b|
|                {3} | 19a+19b-10c-29d 0               0               0      |
|                {3} | 0               19a+19b-10c-29d 0               0      |
|                {3} | 0               0               19a+19b-10c-29d 0      |
|                {3} | 0               0               0               19a+19b|
|                                                                             |
|           2                                                                 |
|      4 : R  <------------------------------------------------------------- R|
|                {4} | 24a-36b-30c-29d -8a-22b-29c-24d  34a+19b-47c-39d  |    |
|                {4} | 19a+19b-10c-29d -38a-16b+39c+21d -18a-13b-43c-15d |    |
|                                                                             |
|o10 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|0                                                                            |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|         -8a-22b-29c-24d  0                0                0                |
|         0                -8a-22b-29c-24d  0                0                |
|         0                0                -8a-22b-29c-24d  0                |
|-30c-29d 0                0                0                -8a-22b-29c-24d  |
|         -38a-16b+39c+21d 0                0                0                |
|         0                -38a-16b+39c+21d 0                0                |
|         0                0                -38a-16b+39c+21d 0                |
|-10c-29d 0                0                0                -38a-16b+39c+21d |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|          0               0               -8a-22b-29c-24d  0                0|
|          0               0               0                -8a-22b-29c-24d  0|
|          0               0               0                0                -|
|b-30c-29d 0               0               0                0                0|
|          24a-36b-30c-29d 0               0                0                0|
|          0               24a-36b-30c-29d 0                0                0|
|          0               0               -38a-16b+39c+21d 0                0|
|          0               0               0                -38a-16b+39c+21d 0|
|          0               0               0                0                -|
|b-10c-29d 0               0               0                0                0|
|          19a+19b-10c-29d 0               0                0                0|
|          0               19a+19b-10c-29d 0                0                0|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|         -8a-22b-29c-24d  0                0                0                |
|         0                -8a-22b-29c-24d  0                0                |
|         0                0                -8a-22b-29c-24d  0                |
|-30c-29d 0                0                0                -8a-22b-29c-24d  |
|         -38a-16b+39c+21d 0                0                0                |
|         0                -38a-16b+39c+21d 0                0                |
|         0                0                -38a-16b+39c+21d 0                |
|-10c-29d 0                0                0                -38a-16b+39c+21d |
|                                                                             |
|3                                                                            |
|  : 4                                                                        |
|-----------------------------------------------------------------------------|
|                                                                         12  |
|----------------------------------------------------------------------- R   :|
|34a+19b-47c-39d  0                0                0                |        |
|0                34a+19b-47c-39d  0                0                |        |
|0                0                34a+19b-47c-39d  0                |        |
|0                0                0                34a+19b-47c-39d  |        |
|-18a-13b-43c-15d 0                0                0                |        |
|0                -18a-13b-43c-15d 0                0                |        |
|0                0                -18a-13b-43c-15d 0                |        |
|0                0                0                -18a-13b-43c-15d |        |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|                0                0                0                34a+19b-47|
|                0                0                0                0         |
|8a-22b-29c-24d  0                0                0                0         |
|                -8a-22b-29c-24d  0                0                0         |
|                0                -8a-22b-29c-24d  0                0         |
|                0                0                -8a-22b-29c-24d  0         |
|                0                0                0                -18a-13b-4|
|                0                0                0                0         |
|38a-16b+39c+21d 0                0                0                0         |
|                -38a-16b+39c+21d 0                0                0         |
|                0                -38a-16b+39c+21d 0                0         |
|                0                0                -38a-16b+39c+21d 0         |
|                                                                             |
|                                                                         12  |
|----------------------------------------------------------------------- R   :|
|34a+19b-47c-39d  0                0                0                |        |
|0                34a+19b-47c-39d  0                0                |        |
|0                0                34a+19b-47c-39d  0                |        |
|0                0                0                34a+19b-47c-39d  |        |
|-18a-13b-43c-15d 0                0                0                |        |
|0                -18a-13b-43c-15d 0                0                |        |
|0                0                -18a-13b-43c-15d 0                |        |
|0                0                0                -18a-13b-43c-15d |        |
|-----------------------------------------------------------------------------|
| 1                                                                           |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|c-39d  0                0                0                0                0 |
|       34a+19b-47c-39d  0                0                0                0 |
|       0                34a+19b-47c-39d  0                0                0 |
|       0                0                34a+19b-47c-39d  0                0 |
|       0                0                0                34a+19b-47c-39d  0 |
|       0                0                0                0                34|
|3c-15d 0                0                0                0                0 |
|       -18a-13b-43c-15d 0                0                0                0 |
|       0                -18a-13b-43c-15d 0                0                0 |
|       0                0                -18a-13b-43c-15d 0                0 |
|       0                0                0                -18a-13b-43c-15d 0 |
|       0                0                0                0                -1|
|                                                                             |
|                                                                             |
| 3                                                                           |
|-----------------------------------------------------------------------------|
|                    18                                                       |
|------------------ R   : 2                                                   |
|               |                                                             |
|               |                                                             |
|               |                                                             |
|               |                                                             |
|               |                                                             |
|a+19b-47c-39d  |                                                             |
|               |                                                             |
|               |                                                             |
|               |                                                             |
|               |                                                             |
|               |                                                             |
|8a-13b-43c-15d |                                                             |
+-----------------------------------------------------------------------------+
|i11 : assert isWellDefined(C ** f')                                          |
+-----------------------------------------------------------------------------+
|i12 : assert isWellDefined(f' ** C)                                          |
+-----------------------------------------------------------------------------+

Tensoring with a complex defines a functor from the category of $R$-modules to
the category of complexes over $R$.

+--------------------------------------------------------------+
|i13 : f'' = random(source f', R^{-2,-2})                      |
|                                                              |
|o13 = {1} | -28a-47b+38c+2d  -16a+7b+15c-23d |                |
|      {1} | 16a+22b+45c-34d  39a+43b-17c-11d |                |
|      {1} | -48a-47b+47c+19d 48a+36b+35c+11d |                |
|                                                              |
|              3       2                                       |
|o13 : Matrix R  <--- R                                        |
+--------------------------------------------------------------+
|i14 : assert((C ** f') * (C ** f'') == C ** (f' * f''))       |
+--------------------------------------------------------------+
|i15 : assert(C ** id_(R^{-1,-2,-3}) == id_(C ** R^{-1,-2,-3}))|
+--------------------------------------------------------------+

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * Complex ** Complex -- tensor product of
    complexes

Ways to use this method:
========================

  * Complex ** Matrix -- create the tensor
    product of a complex and a map of modules
  * "Matrix ** Complex"

Complex == Complex -- whether two complexes are equal
*****************************************************

Synopsis
========

  * Operator: == (Macaulay2Doc),
  * Usage:
        C == D
        C == 0
  * Inputs:
      * C, a complex,
      * D, a complex,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when C and
        D are equal

Description
===========

Two complexes are equal if the corresponding objects and corresponding maps at
each index are equal.

+------------------------------------+
|i1 : S = ZZ/101[a..c]               |
|                                    |
|o1 = S                              |
|                                    |
|o1 : PolynomialRing                 |
+------------------------------------+
|i2 : C = freeResolution coker vars S|
|                                    |
|      1      3      3      1        |
|o2 = S  <-- S  <-- S  <-- S         |
|                                    |
|     0      1      2      3         |
|                                    |
|o2 : Complex                        |
+------------------------------------+
|i3 : D = C[3][-3]                   |
|                                    |
|      1      3      3      1        |
|o3 = S  <-- S  <-- S  <-- S         |
|                                    |
|     0      1      2      3         |
|                                    |
|o3 : Complex                        |
+------------------------------------+
|i4 : C === D                        |
|                                    |
|o4 = false                          |
+------------------------------------+
|i5 : C == D                         |
|                                    |
|o5 = true                           |
+------------------------------------+

Both the maps and the objects must be equal.

+----------------------------------------------------+
|i6 : (lo,hi) = concentration C                      |
|                                                    |
|o6 = (0, 3)                                         |
|                                                    |
|o6 : Sequence                                       |
+----------------------------------------------------+
|i7 : E = complex for i from lo+1 to hi list 0*dd^C_i|
|                                                    |
|      1      3      3      1                        |
|o7 = S  <-- S  <-- S  <-- S                         |
|                                                    |
|     0      1      2      3                         |
|                                                    |
|o7 : Complex                                        |
+----------------------------------------------------+
|i8 : dd^E                                           |
|                                                    |
|          1         3                               |
|o8 = 0 : S  <----- S  : 1                           |
|               0                                    |
|                                                    |
|          3         3                               |
|     1 : S  <----- S  : 2                           |
|               0                                    |
|                                                    |
|          3         1                               |
|     2 : S  <----- S  : 3                           |
|               0                                    |
|                                                    |
|o8 : ComplexMap                                     |
+----------------------------------------------------+
|i9 : C == E                                         |
|                                                    |
|o9 = false                                          |
+----------------------------------------------------+
|i10 : E == 0                                        |
|                                                    |
|o10 = false                                         |
+----------------------------------------------------+

A complex is equal to zero if all the objects and maps are zero. This could
require computation to determine if something that is superficially not zero is
in fact zero.

+-----------------------------------------------------------------------------+
|i11 : f = id_C                                                               |
|                                                                             |
|           1             1                                                   |
|o11 = 0 : S  <--------- S  : 0                                               |
|                | 1 |                                                        |
|                                                                             |
|           3                     3                                           |
|      1 : S  <----------------- S  : 1                                       |
|                {1} | 1 0 0 |                                                |
|                {1} | 0 1 0 |                                                |
|                {1} | 0 0 1 |                                                |
|                                                                             |
|           3                     3                                           |
|      2 : S  <----------------- S  : 2                                       |
|                {2} | 1 0 0 |                                                |
|                {2} | 0 1 0 |                                                |
|                {2} | 0 0 1 |                                                |
|                                                                             |
|           1                 1                                               |
|      3 : S  <------------- S  : 3                                           |
|                {3} | 1 |                                                    |
|                                                                             |
|o11 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i12 : D = coker f                                                            |
|                                                                             |
|o12 = cokernel | 1 | <-- cokernel {1} | 1 0 0 | <-- cokernel {2} | 1 0 0 |   |
|                                  {1} | 0 1 0 |              {2} | 0 1 0 |   |
|      0                           {1} | 0 0 1 |              {2} | 0 0 1 |   |
|                                                                             |
|                         1                          2                        |
|                                                                             |
|o12 : Complex                                                                |
|-----------------------------------------------------------------------------|
|<-- cokernel {3} | 1 |                                                       |
|                                                                             |
|    3                                                                        |
+-----------------------------------------------------------------------------+
|i13 : D == 0                                                                 |
|                                                                             |
|o13 = true                                                                   |
+-----------------------------------------------------------------------------+
+------------------------------------------+
|i14 : C0 = complex S^0                    |
|                                          |
|o14 = 0                                   |
|                                          |
|      0                                   |
|                                          |
|o14 : Complex                             |
+------------------------------------------+
|i15 : C1 = C0[4]                          |
|                                          |
|o15 = 0                                   |
|                                          |
|      -4                                  |
|                                          |
|o15 : Complex                             |
+------------------------------------------+
|i16 : concentration C0 == concentration C1|
|                                          |
|o16 = false                               |
+------------------------------------------+
|i17 : C0 == C1                            |
|                                          |
|o17 = true                                |
+------------------------------------------+
|i18 : C0 == 0                             |
|                                          |
|o18 = true                                |
+------------------------------------------+
|i19 : C1 == 0                             |
|                                          |
|o19 = true                                |
+------------------------------------------+

Testing for equality is not the same testing for isomorphism. In particular,
different presentations of a complex need not be equal.

+----------------------------------------------------+
|i20 : R = QQ[a..d];                                 |
+----------------------------------------------------+
|i21 : f0 = matrix {{-b^2+a*c, b*c-a*d, -c^2+b*d}}   |
|                                                    |
|o21 = | -b2+ac bc-ad -c2+bd |                       |
|                                                    |
|              1       3                             |
|o21 : Matrix R  <--- R                              |
+----------------------------------------------------+
|i22 : f1 = map(source f0,, {{d, c}, {c, b}, {b, a}})|
|                                                    |
|o22 = {2} | d c |                                   |
|      {2} | c b |                                   |
|      {2} | b a |                                   |
|                                                    |
|              3       2                             |
|o22 : Matrix R  <--- R                              |
+----------------------------------------------------+
|i23 : C = complex {f0, f1}                          |
|                                                    |
|       1      3      2                              |
|o23 = R  <-- R  <-- R                               |
|                                                    |
|      0      1      2                               |
|                                                    |
|o23 : Complex                                       |
+----------------------------------------------------+
|i24 : HH C != complex coker f0                      |
|                                                    |
|o24 = true                                          |
+----------------------------------------------------+
|i25 : prune HH C == complex coker f0                |
|                                                    |
|o25 = true                                          |
+----------------------------------------------------+

Caveat
======

Ways to use this method:
========================

  * Complex == Complex -- whether two complexes are
    equal
  * "Complex == ZZ"
  * "ZZ == Complex"

Complex _ Array -- the canonical inclusion or projection map of a direct sum
****************************************************************************

Synopsis
========

  * Operator: _ (Macaulay2Doc),
  * Usage:
        i = C_[name]
        p = C^[name]
  * Inputs:
      * C, a complex,
      * name, an array (Macaulay2Doc),
  * Outputs:
      * a map of complexes, i is the canonical inclusion and
        p is the canonical projection

Description
===========

The direct sum is an n-ary operator with projection and inclusion maps from
each component satisfying appropriate identities.

One can access these maps as follows.

+-----------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c];                                          |
+-----------------------------------------------------------------+
|i2 : C1 = freeResolution coker vars S                            |
|                                                                 |
|      1      3      3      1                                     |
|o2 = S  <-- S  <-- S  <-- S                                      |
|                                                                 |
|     0      1      2      3                                      |
|                                                                 |
|o2 : Complex                                                     |
+-----------------------------------------------------------------+
|i3 : C2 = complex (ideal(a,b,c))                                 |
|                                                                 |
|o3 = image | a b c |                                             |
|                                                                 |
|     0                                                           |
|                                                                 |
|o3 : Complex                                                     |
+-----------------------------------------------------------------+
|i4 : D = C1 ++ C2                                                |
|                                                                 |
|                            3      3      1                      |
|o4 = image | 1 0 0 0 | <-- S  <-- S  <-- S                       |
|           | 0 a b c |                                           |
|                           1      2      3                       |
|     0                                                           |
|                                                                 |
|o4 : Complex                                                     |
+-----------------------------------------------------------------+
|i5 : D_[0]                                                       |
|                                                                 |
|                                           1                     |
|o5 = 0 : image | 1 0 0 0 | <------------- S  : 0                 |
|               | 0 a b c |    {0} | 1 |                          |
|                              {1} | 0 |                          |
|                              {1} | 0 |                          |
|                              {1} | 0 |                          |
|                                                                 |
|          3                     3                                |
|     1 : S  <----------------- S  : 1                            |
|               {1} | 1 0 0 |                                     |
|               {1} | 0 1 0 |                                     |
|               {1} | 0 0 1 |                                     |
|                                                                 |
|          3                     3                                |
|     2 : S  <----------------- S  : 2                            |
|               {2} | 1 0 0 |                                     |
|               {2} | 0 1 0 |                                     |
|               {2} | 0 0 1 |                                     |
|                                                                 |
|          1                 1                                    |
|     3 : S  <------------- S  : 3                                |
|               {3} | 1 |                                         |
|                                                                 |
|o5 : ComplexMap                                                  |
+-----------------------------------------------------------------+
|i6 : D_[1]                                                       |
|                                                                 |
|o6 = 0 : image | 1 0 0 0 | <----------------- image | a b c | : 0|
|               | 0 a b c |    {0} | 0 0 0 |                      |
|                              {1} | 1 0 0 |                      |
|                              {1} | 0 1 0 |                      |
|                              {1} | 0 0 1 |                      |
|                                                                 |
|o6 : ComplexMap                                                  |
+-----------------------------------------------------------------+
|i7 : D^[0] * D_[0] == 1                                          |
|                                                                 |
|o7 = true                                                        |
+-----------------------------------------------------------------+
|i8 : D^[1] * D_[1] == 1                                          |
|                                                                 |
|o8 = true                                                        |
+-----------------------------------------------------------------+
|i9 : D^[0] * D_[1] == 0                                          |
|                                                                 |
|o9 = true                                                        |
+-----------------------------------------------------------------+
|i10 : D^[1] * D_[0] == 0                                         |
|                                                                 |
|o10 = true                                                       |
+-----------------------------------------------------------------+
|i11 : D_[0] * D^[0] + D_[1] * D^[1] == 1                         |
|                                                                 |
|o11 = true                                                       |
+-----------------------------------------------------------------+

The default names for the components are the non-negative integers.  However,
one can choose any name.

+------------------------------------------------------------------+
|i12 : E = (mike => C1) ++ (greg => C2)                            |
|                                                                  |
|                             3      3      1                      |
|o12 = image | 1 0 0 0 | <-- S  <-- S  <-- S                       |
|            | 0 a b c |                                           |
|                            1      2      3                       |
|      0                                                           |
|                                                                  |
|o12 : Complex                                                     |
+------------------------------------------------------------------+
|i13 : E_[mike]                                                    |
|                                                                  |
|                                            1                     |
|o13 = 0 : image | 1 0 0 0 | <------------- S  : 0                 |
|                | 0 a b c |    {0} | 1 |                          |
|                               {1} | 0 |                          |
|                               {1} | 0 |                          |
|                               {1} | 0 |                          |
|                                                                  |
|           3                     3                                |
|      1 : S  <----------------- S  : 1                            |
|                {1} | 1 0 0 |                                     |
|                {1} | 0 1 0 |                                     |
|                {1} | 0 0 1 |                                     |
|                                                                  |
|           3                     3                                |
|      2 : S  <----------------- S  : 2                            |
|                {2} | 1 0 0 |                                     |
|                {2} | 0 1 0 |                                     |
|                {2} | 0 0 1 |                                     |
|                                                                  |
|           1                 1                                    |
|      3 : S  <------------- S  : 3                                |
|                {3} | 1 |                                         |
|                                                                  |
|o13 : ComplexMap                                                  |
+------------------------------------------------------------------+
|i14 : E_[greg]                                                    |
|                                                                  |
|o14 = 0 : image | 1 0 0 0 | <----------------- image | a b c | : 0|
|                | 0 a b c |    {0} | 0 0 0 |                      |
|                               {1} | 1 0 0 |                      |
|                               {1} | 0 1 0 |                      |
|                               {1} | 0 0 1 |                      |
|                                                                  |
|o14 : ComplexMap                                                  |
+------------------------------------------------------------------+
|i15 : E^[mike] * E_[mike] == 1                                    |
|                                                                  |
|o15 = true                                                        |
+------------------------------------------------------------------+
|i16 : E^[greg] * E_[greg] == 1                                    |
|                                                                  |
|o16 = true                                                        |
+------------------------------------------------------------------+
|i17 : E^[mike] * E_[greg] == 0                                    |
|                                                                  |
|o17 = true                                                        |
+------------------------------------------------------------------+
|i18 : E^[greg] * E_[mike] == 0                                    |
|                                                                  |
|o18 = true                                                        |
+------------------------------------------------------------------+
|i19 : E_[mike] * E^[mike] + E_[greg] * E^[greg] == 1              |
|                                                                  |
|o19 = true                                                        |
+------------------------------------------------------------------+

One can also access inclusion and projection maps of sub-direct sums.

+----------------------------------------------------------------------+
|i20 : F = directSum(C1, C2, (complex S^13)[-4])                       |
|                                                                      |
|                             3      3      1      13                  |
|o20 = image | 1 0 0 0 | <-- S  <-- S  <-- S  <-- S                    |
|            | 0 a b c |                                               |
|                            1      2      3      4                    |
|      0                                                               |
|                                                                      |
|o20 : Complex                                                         |
+----------------------------------------------------------------------+
|i21 : F^[0,1]                                                         |
|                                                                      |
|o21 = 0 : image | 1 0 0 0 | <------------------- image | 1 0 0 0 | : 0|
|                | 0 a b c |    {0} | 1 0 0 0 |         | 0 a b c |    |
|                               {1} | 0 1 0 0 |                        |
|                               {1} | 0 0 1 0 |                        |
|                               {1} | 0 0 0 1 |                        |
|                                                                      |
|           3                     3                                    |
|      1 : S  <----------------- S  : 1                                |
|                {1} | 1 0 0 |                                         |
|                {1} | 0 1 0 |                                         |
|                {1} | 0 0 1 |                                         |
|                                                                      |
|           3                     3                                    |
|      2 : S  <----------------- S  : 2                                |
|                {2} | 1 0 0 |                                         |
|                {2} | 0 1 0 |                                         |
|                {2} | 0 0 1 |                                         |
|                                                                      |
|           1                 1                                        |
|      3 : S  <------------- S  : 3                                    |
|                {3} | 1 |                                             |
|                                                                      |
|                    13                                                |
|      4 : 0 <----- S   : 4                                            |
|               0                                                      |
|                                                                      |
|o21 : ComplexMap                                                      |
+----------------------------------------------------------------------+
|i22 : F_[0,2]                                                         |
|                                                                      |
|                                            1                         |
|o22 = 0 : image | 1 0 0 0 | <------------- S  : 0                     |
|                | 0 a b c |    {0} | 1 |                              |
|                               {1} | 0 |                              |
|                               {1} | 0 |                              |
|                               {1} | 0 |                              |
|                                                                      |
|           3                     3                                    |
|      1 : S  <----------------- S  : 1                                |
|                {1} | 1 0 0 |                                         |
|                {1} | 0 1 0 |                                         |
|                {1} | 0 0 1 |                                         |
|                                                                      |
|           3                     3                                    |
|      2 : S  <----------------- S  : 2                                |
|                {2} | 1 0 0 |                                         |
|                {2} | 0 1 0 |                                         |
|                {2} | 0 0 1 |                                         |
|                                                                      |
|           1                 1                                        |
|      3 : S  <------------- S  : 3                                    |
|                {3} | 1 |                                             |
|                                                                      |
|           13                                     13                  |
|      4 : S   <--------------------------------- S   : 4              |
|                 | 1 0 0 0 0 0 0 0 0 0 0 0 0 |                        |
|                 | 0 1 0 0 0 0 0 0 0 0 0 0 0 |                        |
|                 | 0 0 1 0 0 0 0 0 0 0 0 0 0 |                        |
|                 | 0 0 0 1 0 0 0 0 0 0 0 0 0 |                        |
|                 | 0 0 0 0 1 0 0 0 0 0 0 0 0 |                        |
|                 | 0 0 0 0 0 1 0 0 0 0 0 0 0 |                        |
|                 | 0 0 0 0 0 0 1 0 0 0 0 0 0 |                        |
|                 | 0 0 0 0 0 0 0 1 0 0 0 0 0 |                        |
|                 | 0 0 0 0 0 0 0 0 1 0 0 0 0 |                        |
|                 | 0 0 0 0 0 0 0 0 0 1 0 0 0 |                        |
|                 | 0 0 0 0 0 0 0 0 0 0 1 0 0 |                        |
|                 | 0 0 0 0 0 0 0 0 0 0 0 1 0 |                        |
|                 | 0 0 0 0 0 0 0 0 0 0 0 0 1 |                        |
|                                                                      |
|o22 : ComplexMap                                                      |
+----------------------------------------------------------------------+

See also
========

  * directSum(Complex) -- direct sum of
    complexes
  * components(Complex) -- list the components
    of a direct sum
  * indices (Macaulay2Doc) -- indices of a polynomial; also
    components for a direct sum

Ways to use this method:
========================

  * Complex _ Array -- the canonical inclusion or
    projection map of a direct sum

Complex _ ZZ -- access individual object in a complex
*****************************************************

Synopsis
========

  * Operator: _ (Macaulay2Doc),
  * Usage:
        C_i
        C^i
  * Inputs:
      * C, a complex,
      * i, an integer (Macaulay2Doc), either the homological or
        cohomological index
  * Outputs:
      * a module (Macaulay2Doc), the i-th object

Description
===========

Complexes can be either chain complexes or cochain complexes.  Subscripts refer
to homological indices, and superscripts refer to cohomological indices.

In this package homological indices are used by default.  For example, the
concentration, references homological indices.
Nevertheless, we always have the equation $C^i = C_{-i}$.

+------------------------------------+
|i1 : S = ZZ/101[a..c]               |
|                                    |
|o1 = S                              |
|                                    |
|o1 : PolynomialRing                 |
+------------------------------------+
|i2 : C = freeResolution coker vars S|
|                                    |
|      1      3      3      1        |
|o2 = S  <-- S  <-- S  <-- S         |
|                                    |
|     0      1      2      3         |
|                                    |
|o2 : Complex                        |
+------------------------------------+
|i3 : C_2                            |
|                                    |
|      3                             |
|o3 = S                              |
|                                    |
|o3 : S-module, free, degrees {3:2}  |
+------------------------------------+
|i4 : C^(-2)                         |
|                                    |
|      3                             |
|o4 = S                              |
|                                    |
|o4 : S-module, free, degrees {3:2}  |
+------------------------------------+
|i5 : C_2 == C^(-2)                  |
|                                    |
|o5 = true                           |
+------------------------------------+

Indices that are outside of the concentration automatically return the zero
object.

+-------------+
|i6 : C_-7    |
|             |
|o6 = 0       |
|             |
|o6 : S-module|
+-------------+

Ways to use this method:
========================

  * Complex _ ZZ -- access individual object in a
    complex

Complex Array -- shift a complex or complex map
***********************************************

Synopsis
========

  * Operator: SPACE (Macaulay2Doc),
  * Usage:
        D = C[i]
        g = f[i]
  * Inputs:
      * C, a complex, or f, a ComplexMap,
      * an array (Macaulay2Doc), [i], where i is an integer
  * Outputs:
      * D, a complex, or g, a ComplexMap.

Description
===========

The shifted complex $D$ is defined by $D_j = C_{i+j}$ for all $j$ and the sign
of the differential is changed if $i$ is odd.

The shifted complex map $g$ is defined by $g_j = f_{i+j}$ for all $j$.

The shift defines a natural automorphism on the category of complexes.
Topologists often call the shifted complex $C[1]$ the suspension of $C$.

+------------------------------------+
|i1 : S = ZZ/101[a..d]               |
|                                    |
|o1 = S                              |
|                                    |
|o1 : PolynomialRing                 |
+------------------------------------+
|i2 : C = freeResolution coker vars S|
|                                    |
|      1      4      6      4      1 |
|o2 = S  <-- S  <-- S  <-- S  <-- S  |
|                                    |
|     0      1      2      3      4  |
|                                    |
|o2 : Complex                        |
+------------------------------------+
|i3 : dd^C_3                         |
|                                    |
|o3 = {2} | c  d  0  0  |            |
|     {2} | -b 0  d  0  |            |
|     {2} | a  0  0  d  |            |
|     {2} | 0  -b -c 0  |            |
|     {2} | 0  a  0  -c |            |
|     {2} | 0  0  a  b  |            |
|                                    |
|             6       4              |
|o3 : Matrix S  <--- S               |
+------------------------------------+
|i4 : D = C[1]                       |
|                                    |
|      1      4      6      4      1 |
|o4 = S  <-- S  <-- S  <-- S  <-- S  |
|                                    |
|     -1     0      1      2      3  |
|                                    |
|o4 : Complex                        |
+------------------------------------+
|i5 : assert isWellDefined D         |
+------------------------------------+
|i6 : assert(dd^D_2 == -dd^C_3)      |
+------------------------------------+

In order to shift the complex one step, and not change the differential, one
can do the following.

+-----------------------------------+
|i7 : E = complex(C, Base => -1)    |
|                                   |
|      1      4      6      4      1|
|o7 = S  <-- S  <-- S  <-- S  <-- S |
|                                   |
|     -1     0      1      2      3 |
|                                   |
|o7 : Complex                       |
+-----------------------------------+
|i8 : assert isWellDefined E        |
+-----------------------------------+
|i9 : assert(dd^E_2 == dd^C_3)      |
+-----------------------------------+

The shift operator is functorial, as illustrated below.

+-----------------------------------------------------+
|i10 : C2 = freeResolution (S^1/(a^2, b^2, c^2, d^2)) |
|                                                     |
|       1      4      6      4      1                 |
|o10 = S  <-- S  <-- S  <-- S  <-- S                  |
|                                                     |
|      0      1      2      3      4                  |
|                                                     |
|o10 : Complex                                        |
+-----------------------------------------------------+
|i11 : C3 = freeResolution (S^1/(a^2, b^3, c^4, d^5)) |
|                                                     |
|       1      4      6      4      1                 |
|o11 = S  <-- S  <-- S  <-- S  <-- S                  |
|                                                     |
|      0      1      2      3      4                  |
|                                                     |
|o11 : Complex                                        |
+-----------------------------------------------------+
|i12 : f2 = extend(C, C2, map(C_0, C2_0, 1))          |
|                                                     |
|           1             1                           |
|o12 = 0 : S  <--------- S  : 0                       |
|                | 1 |                                |
|                                                     |
|           4                       4                 |
|      1 : S  <------------------- S  : 1             |
|                {1} | a 0 0 0 |                      |
|                {1} | 0 b 0 0 |                      |
|                {1} | 0 0 c 0 |                      |
|                {1} | 0 0 0 d |                      |
|                                                     |
|           6                                 6       |
|      2 : S  <----------------------------- S  : 2   |
|                {2} | ab 0  0  0  0  0  |            |
|                {2} | 0  ac 0  0  0  0  |            |
|                {2} | 0  0  bc 0  0  0  |            |
|                {2} | 0  0  0  ad 0  0  |            |
|                {2} | 0  0  0  0  bd 0  |            |
|                {2} | 0  0  0  0  0  cd |            |
|                                                     |
|           4                               4         |
|      3 : S  <--------------------------- S  : 3     |
|                {3} | abc 0   0   0   |              |
|                {3} | 0   abd 0   0   |              |
|                {3} | 0   0   acd 0   |              |
|                {3} | 0   0   0   bcd |              |
|                                                     |
|           1                    1                    |
|      4 : S  <---------------- S  : 4                |
|                {4} | abcd |                         |
|                                                     |
|o12 : ComplexMap                                     |
+-----------------------------------------------------+
|i13 : f3 = extend(C2, C3, map(C2_0, C3_0, 1))        |
|                                                     |
|           1             1                           |
|o13 = 0 : S  <--------- S  : 0                       |
|                | 1 |                                |
|                                                     |
|           4                         4               |
|      1 : S  <--------------------- S  : 1           |
|                {2} | 1 0 0  0  |                    |
|                {2} | 0 b 0  0  |                    |
|                {2} | 0 0 c2 0  |                    |
|                {2} | 0 0 0  d3 |                    |
|                                                     |
|           6                                    6    |
|      2 : S  <-------------------------------- S  : 2|
|                {4} | b 0  0   0  0   0    |         |
|                {4} | 0 c2 0   0  0   0    |         |
|                {4} | 0 0  bc2 0  0   0    |         |
|                {4} | 0 0  0   d3 0   0    |         |
|                {4} | 0 0  0   0  bd3 0    |         |
|                {4} | 0 0  0   0  0   c2d3 |         |
|                                                     |
|           4                                  4      |
|      3 : S  <------------------------------ S  : 3  |
|                {6} | bc2 0   0    0     |           |
|                {6} | 0   bd3 0    0     |           |
|                {6} | 0   0   c2d3 0     |           |
|                {6} | 0   0   0    bc2d3 |           |
|                                                     |
|           1                     1                   |
|      4 : S  <----------------- S  : 4               |
|                {8} | bc2d3 |                        |
|                                                     |
|o13 : ComplexMap                                     |
+-----------------------------------------------------+
|i14 : assert((f2*f3)[1] == (f2[1]) * (f3[1]))        |
+-----------------------------------------------------+
|i15 : assert(source(f2[1]) == C2[1])                 |
+-----------------------------------------------------+
|i16 : assert(target(f2[1]) == C[1])                  |
+-----------------------------------------------------+

See also
========

  * concentration -- indices on which a complex may be
    non-zero
  * complex(Complex) -- make a complex by
    reindexing the terms of the complex
  * extend(Complex,Complex,Matrix)
    -- extend a map of
    modules to a map of chain complexes

Ways to use this method:
========================

  * Complex Array -- shift a complex or complex map
  * "ComplexMap Array"

complex(ChainComplex) -- translate between data types for chain complexes
*************************************************************************

Synopsis
========

  * Function: complex,
  * Usage:
        D = complex C
  * Inputs:
      * C, a chain complex (Macaulay2Doc),
  * Optional inputs (Macaulay2Doc),:
      * Base, => ..., default value 0, make a chain complex
  * Outputs:
      * D, a complex,

Description
===========

Both ChainComplex and Complex are Macaulay2 types that implement chain
complexes of modules over rings. The plan is to replace ChainComplex with this
new type. Before this happens, this function allows interoperability between
these types.

The first example is the minimal free resolution of the twisted cubic curve.

+------------------------------------------+
|i1 : R = ZZ/32003[a..d];                  |
+------------------------------------------+
|i2 : I = monomialCurveIdeal(R, {1,2,3})   |
|                                          |
|             2                    2       |
|o2 = ideal (c  - b*d, b*c - a*d, b  - a*c)|
|                                          |
|o2 : Ideal of R                           |
+------------------------------------------+
|i3 : M = R^1/I                            |
|                                          |
|o3 = cokernel | c2-bd bc-ad b2-ac |       |
|                                          |
|                            1             |
|o3 : R-module, quotient of R              |
+------------------------------------------+
|i4 : C = resolution M                     |
|                                          |
|      1      3      2                     |
|o4 = R  <-- R  <-- R  <-- 0               |
|                                          |
|     0      1      2      3               |
|                                          |
|o4 : ChainComplex                         |
+------------------------------------------+
|i5 : D = complex C                        |
|                                          |
|      1      3      2                     |
|o5 = R  <-- R  <-- R                      |
|                                          |
|     0      1      2                      |
|                                          |
|o5 : Complex                              |
+------------------------------------------+
|i6 : D1 = freeResolution M                |
|                                          |
|      1      3      2                     |
|o6 = R  <-- R  <-- R                      |
|                                          |
|     0      1      2                      |
|                                          |
|o6 : Complex                              |
+------------------------------------------+
|i7 : assert(D == D1)                      |
+------------------------------------------+

In the following example, note that a different choice of sign is chosen in the
new Complexes package.

+----------------------------+
|i8 : C1 = Hom(C, R^1)       |
|                            |
|             2      3      1|
|o8 = 0  <-- R  <-- R  <-- R |
|                            |
|     -3     -2     -1     0 |
|                            |
|o8 : ChainComplex           |
+----------------------------+
|i9 : D1 = complex C1        |
|                            |
|      2      3      1       |
|o9 = R  <-- R  <-- R        |
|                            |
|     -2     -1     0        |
|                            |
|o9 : Complex                |
+----------------------------+
|i10 : D2 = Hom(D, R^1)      |
|                            |
|       2      3      1      |
|o10 = R  <-- R  <-- R       |
|                            |
|      -2     -1     0       |
|                            |
|o10 : Complex               |
+----------------------------+
|i11 : D1.dd_-1              |
|                            |
|o11 = {-3} | c  -b a  |     |
|      {-3} | -d c  -b |     |
|                            |
|              2       3     |
|o11 : Matrix R  <--- R      |
+----------------------------+
|i12 : D2.dd_-1              |
|                            |
|o12 = {-3} | -c b  -a |     |
|      {-3} | d  -c b  |     |
|                            |
|              2       3     |
|o12 : Matrix R  <--- R      |
+----------------------------+
|i13 : assert(D1 != D2)      |
+----------------------------+

Caveat
======

This is a temporary method to allow comparisons among the data types, and will
be removed once the older data structure is replaced

See also
========

  * chainComplex(Complex) -- translate
    between data types for chain complexes
  * chainComplex(ComplexMap) -- translate
    between data types for chain complexes
  * complex(ChainComplexMap) -- translate
    between data types for chain complex maps

Ways to use this method:
========================

  * complex(ChainComplex) -- translate
    between data types for chain complexes

complex(ChainComplexMap) -- translate between data types for chain complex maps
*******************************************************************************

Synopsis
========

  * Function: complex,
  * Usage:
        g = complex f
  * Inputs:
      * f, a chain complex map (Macaulay2Doc),
  * Optional inputs (Macaulay2Doc),:
      * Base, => ..., default value 0, make a chain complex
  * Outputs:
      * g, a map of complexes,

Description
===========

Both ChainComplexMap and ComplexMap are Macaulay2 types that implement maps
between chain complexes. The plan is to replace ChainComplexMap with this new
type. Before this happens, this function allows interoperability between these
types.

The first example is the minimal free resolution of the twisted cubic curve.

+---------------------------------------------+
|i1 : R = ZZ/32003[a..d];                     |
+---------------------------------------------+
|i2 : I = monomialCurveIdeal(R, {1,2,3})      |
|                                             |
|             2                    2          |
|o2 = ideal (c  - b*d, b*c - a*d, b  - a*c)   |
|                                             |
|o2 : Ideal of R                              |
+---------------------------------------------+
|i3 : M = R^1/I                               |
|                                             |
|o3 = cokernel | c2-bd bc-ad b2-ac |          |
|                                             |
|                            1                |
|o3 : R-module, quotient of R                 |
+---------------------------------------------+
|i4 : C = resolution M                        |
|                                             |
|      1      3      2                        |
|o4 = R  <-- R  <-- R  <-- 0                  |
|                                             |
|     0      1      2      3                  |
|                                             |
|o4 : ChainComplex                            |
+---------------------------------------------+
|i5 : f = C.dd                                |
|                                             |
|          1                             3    |
|o5 = 0 : R  <------------------------- R  : 1|
|               | b2-ac bc-ad c2-bd |         |
|                                             |
|          3                     2            |
|     1 : R  <----------------- R  : 2        |
|               {2} | -c d  |                 |
|               {2} | b  -c |                 |
|               {2} | -a b  |                 |
|                                             |
|          2                                  |
|     2 : R  <----- 0 : 3                     |
|               0                             |
|                                             |
|o5 : ChainComplexMap                         |
+---------------------------------------------+
|i6 : g = complex f                           |
|                                             |
|          1                             3    |
|o6 = 0 : R  <------------------------- R  : 1|
|               | b2-ac bc-ad c2-bd |         |
|                                             |
|          3                     2            |
|     1 : R  <----------------- R  : 2        |
|               {2} | -c d  |                 |
|               {2} | b  -c |                 |
|               {2} | -a b  |                 |
|                                             |
|o6 : ComplexMap                              |
+---------------------------------------------+
|i7 : isWellDefined g                         |
|                                             |
|o7 = true                                    |
+---------------------------------------------+
|i8 : D = freeResolution M                    |
|                                             |
|      1      3      2                        |
|o8 = R  <-- R  <-- R                         |
|                                             |
|     0      1      2                         |
|                                             |
|o8 : Complex                                 |
+---------------------------------------------+
|i9 : assert(D.dd == g)                       |
+---------------------------------------------+

The following two extension of maps between modules to maps between chain
complexes agree.

+------------------------------------------+
|i10 : J = ideal vars R                    |
|                                          |
|o10 = ideal (a, b, c, d)                  |
|                                          |
|o10 : Ideal of R                          |
+------------------------------------------+
|i11 : C1 = resolution(R^1/J)              |
|                                          |
|       1      4      6      4      1      |
|o11 = R  <-- R  <-- R  <-- R  <-- R  <-- 0|
|                                          |
|      0      1      2      3      4      5|
|                                          |
|o11 : ChainComplex                        |
+------------------------------------------+
|i12 : D1 = freeResolution(R^1/J)          |
|                                          |
|       1      4      6      4      1      |
|o12 = R  <-- R  <-- R  <-- R  <-- R       |
|                                          |
|      0      1      2      3      4       |
|                                          |
|o12 : Complex                             |
+------------------------------------------+
|i13 : f = extend(C1, C, matrix{{1_R}})    |
|                                          |
|           1             1                |
|o13 = 0 : R  <--------- R  : 0            |
|                | 1 |                     |
|                                          |
|           4                        3     |
|      1 : R  <-------------------- R  : 1 |
|                {1} | 0  0  0  |          |
|                {1} | b  0  0  |          |
|                {1} | -a b  c  |          |
|                {1} | 0  -a -b |          |
|                                          |
|           6                    2         |
|      2 : R  <---------------- R  : 2     |
|                {2} | 0 0  |              |
|                {2} | 0 0  |              |
|                {2} | b 0  |              |
|                {2} | 0 0  |              |
|                {2} | 0 -b |              |
|                {2} | 0 a  |              |
|                                          |
|           4                              |
|      3 : R  <----- 0 : 3                 |
|                0                         |
|                                          |
|o13 : ChainComplexMap                     |
+------------------------------------------+
|i14 : g = complex f                       |
|                                          |
|           1             1                |
|o14 = 0 : R  <--------- R  : 0            |
|                | 1 |                     |
|                                          |
|           4                        3     |
|      1 : R  <-------------------- R  : 1 |
|                {1} | 0  0  0  |          |
|                {1} | b  0  0  |          |
|                {1} | -a b  c  |          |
|                {1} | 0  -a -b |          |
|                                          |
|           6                    2         |
|      2 : R  <---------------- R  : 2     |
|                {2} | 0 0  |              |
|                {2} | 0 0  |              |
|                {2} | b 0  |              |
|                {2} | 0 0  |              |
|                {2} | 0 -b |              |
|                {2} | 0 a  |              |
|                                          |
|o14 : ComplexMap                          |
+------------------------------------------+
|i15 : g1 = extend(D1, D, matrix{{1_R}})   |
|                                          |
|           1             1                |
|o15 = 0 : R  <--------- R  : 0            |
|                | 1 |                     |
|                                          |
|           4                        3     |
|      1 : R  <-------------------- R  : 1 |
|                {1} | 0  0  0  |          |
|                {1} | b  0  0  |          |
|                {1} | -a b  c  |          |
|                {1} | 0  -a -b |          |
|                                          |
|           6                    2         |
|      2 : R  <---------------- R  : 2     |
|                {2} | 0 0  |              |
|                {2} | 0 0  |              |
|                {2} | b 0  |              |
|                {2} | 0 0  |              |
|                {2} | 0 -b |              |
|                {2} | 0 a  |              |
|                                          |
|o15 : ComplexMap                          |
+------------------------------------------+
|i16 : assert(g == g1)                     |
+------------------------------------------+

Caveat
======

This is a temporary method to allow comparisons among the data types, and will
be removed once the older data structure is replaced

See also
========

  * chainComplex(ComplexMap) -- translate
    between data types for chain complexes
  * complex(ChainComplex) -- translate
    between data types for chain complexes
  * chainComplex(Complex) -- translate
    between data types for chain complexes

Ways to use this method:
========================

  * complex(ChainComplexMap) -- translate
    between data types for chain complex maps

complex(Complex) -- make a complex by reindexing the terms of the complex
*************************************************************************

Synopsis
========

  * Function: complex,
  * Usage:
        D = complex(C, Base => i)
  * Inputs:
      * C, a complex,
  * Optional inputs (Macaulay2Doc),:
      * Base, => an integer (Macaulay2Doc), default
        value 0, the target of the lowest differential
  * Outputs:
      * D, a complex, where if $d$ is the smallest index of the
        target of the differentials of C, then for all integers $j$ we have
        $D_{i+j} = C_{d+j}$

Description
===========

This returns an alteration of the input complex, reindexing the terms of the
complex.

+-------------------------------------+
|i1 : S = ZZ/101[a..d]                |
|                                     |
|o1 = S                               |
|                                     |
|o1 : PolynomialRing                  |
+-------------------------------------+
|i2 : C = freeResolution coker vars S |
|                                     |
|      1      4      6      4      1  |
|o2 = S  <-- S  <-- S  <-- S  <-- S   |
|                                     |
|     0      1      2      3      4   |
|                                     |
|o2 : Complex                         |
+-------------------------------------+
|i3 : D = complex(C, Base => 1)       |
|                                     |
|      1      4      6      4      1  |
|o3 = S  <-- S  <-- S  <-- S  <-- S   |
|                                     |
|     1      2      3      4      5   |
|                                     |
|o3 : Complex                         |
+-------------------------------------+
|i4 : E = complex(D, Base => -11)     |
|                                     |
|      1       4       6      4      1|
|o4 = S   <-- S   <-- S  <-- S  <-- S |
|                                     |
|     -11     -10     -9     -8     -7|
|                                     |
|o4 : Complex                         |
+-------------------------------------+
|i5 : dd^D_2 == dd^C_1                |
|                                     |
|o5 = true                            |
+-------------------------------------+
|i6 : dd^E_-9 == dd^C_2               |
|                                     |
|o6 = true                            |
+-------------------------------------+

Rather than specifying the homological degree of the lowest target, one can
also shift the homological degree, which may simultaneously negate the maps.

+-----------------------------------+
|i7 : F = C[-1]                     |
|                                   |
|      1      4      6      4      1|
|o7 = S  <-- S  <-- S  <-- S  <-- S |
|                                   |
|     1      2      3      4      5 |
|                                   |
|o7 : Complex                       |
+-----------------------------------+
|i8 : for i from min F to max F list|
|         dd^F_i == - dd^D_i        |
|                                   |
|o8 = {true, true, true, true, true}|
|                                   |
|o8 : List                          |
+-----------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * isWellDefined(Complex) -- whether a
    complex is well-defined
  * complex(HashTable) -- make a chain complex
  * complex(List) -- make a chain complex
  * Complex Array -- shift a complex or complex map

Ways to use this method:
========================

  * complex(Complex) -- make a complex by
    reindexing the terms of the complex

complex(ComplexMap) -- make a complex by specifying the differential
********************************************************************

Synopsis
========

  * Function: complex,
  * Usage:
        C = complex d
  * Inputs:
      * d, a map of complexes,
  * Optional inputs (Macaulay2Doc),:
      * Base, => an integer (Macaulay2Doc), default
        value 0, unused
  * Outputs:
      * C, a complex, whose differential is $d$

Description
===========

Given a map $d$ of complexes having degree -1 and whose source and targets are
equal, this method constructs the chain complex whose differential is $d$.
This constructor does not verify that $d^2 = 0$.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[x_1..x_4];                                                   |
+-----------------------------------------------------------------------------+
|i2 : F = freeResolution coker vars S                                         |
|                                                                             |
|      1      4      6      4      1                                          |
|o2 = S  <-- S  <-- S  <-- S  <-- S                                           |
|                                                                             |
|     0      1      2      3      4                                           |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : d = randomComplexMap(F, F, Cycle => true, InternalDegree => -1, Degree  |
|                                                                             |
|                    1                                                        |
|o3 = -1 : 0 <----- S  : 0                                                    |
|               0                                                             |
|                                                                             |
|          1                          4                                       |
|     0 : S  <---------------------- S  : 1                                   |
|               | -29 30 -36 -24 |                                            |
|                                                                             |
|          4                                     6                            |
|     1 : S  <--------------------------------- S  : 2                        |
|               {1} | -30 36  0  24  0  0   |                                 |
|               {1} | -29 0   36 0   24 0   |                                 |
|               {1} | 0   -29 30 0   0  24  |                                 |
|               {1} | 0   0   0  -29 30 -36 |                                 |
|                                                                             |
|          6                               4                                  |
|     2 : S  <--------------------------- S  : 3                              |
|               {2} | -36 -24 0   0   |                                       |
|               {2} | -30 0   -24 0   |                                       |
|               {2} | -29 0   0   -24 |                                       |
|               {2} | 0   -30 36  0   |                                       |
|               {2} | 0   -29 0   36  |                                       |
|               {2} | 0   0   -29 30  |                                       |
|                                                                             |
|          4                   1                                              |
|     3 : S  <--------------- S  : 4                                          |
|               {3} | 24  |                                                   |
|               {3} | -36 |                                                   |
|               {3} | -30 |                                                   |
|               {3} | -29 |                                                   |
|                                                                             |
|o3 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|=> -1)                                                                       |
+-----------------------------------------------------------------------------+
|i4 : d^2                                                                     |
|                                                                             |
|o4 = 0                                                                       |
|                                                                             |
|o4 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i5 : C = complex d                                                           |
|                                                                             |
|      1      4      6      4      1                                          |
|o5 = S  <-- S  <-- S  <-- S  <-- S                                           |
|                                                                             |
|     0      1      2      3      4                                           |
|                                                                             |
|o5 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i6 : assert isWellDefined C                                                  |
+-----------------------------------------------------------------------------+
|i7 : assert all(0..4, i -> dd^C_i == d_i)                                    |
+-----------------------------------------------------------------------------+
+-------------------------------------------------------------------+
|i8 : e = randomComplexMap(F, F, InternalDegree => -1, Degree => -1)|
|                                                                   |
|                    1                                              |
|o8 = -1 : 0 <----- S  : 0                                          |
|               0                                                   |
|                                                                   |
|          1                         4                              |
|     0 : S  <--------------------- S  : 1                          |
|               | 19 19 -10 -29 |                                   |
|                                                                   |
|          4                                       6                |
|     1 : S  <----------------------------------- S  : 2            |
|               {1} | -8  -38 34  -18 -28 16  |                     |
|               {1} | -22 -16 19  -13 -47 22  |                     |
|               {1} | -29 39  -47 -43 38  45  |                     |
|               {1} | -24 21  -39 -15 2   -34 |                     |
|                                                                   |
|          6                               4                        |
|     2 : S  <--------------------------- S  : 3                    |
|               {2} | -48 15  48  40  |                             |
|               {2} | -47 -23 36  11  |                             |
|               {2} | 47  39  35  46  |                             |
|               {2} | 19  43  11  -28 |                             |
|               {2} | -16 -17 -38 1   |                             |
|               {2} | 7   -11 33  -3  |                             |
|                                                                   |
|          4                   1                                    |
|     3 : S  <--------------- S  : 4                                |
|               {3} | 22  |                                         |
|               {3} | -47 |                                         |
|               {3} | -23 |                                         |
|               {3} | -7  |                                         |
|                                                                   |
|o8 : ComplexMap                                                    |
+-------------------------------------------------------------------+
|i9 : D = complex e                                                 |
|                                                                   |
|      1      4      6      4      1                                |
|o9 = S  <-- S  <-- S  <-- S  <-- S                                 |
|                                                                   |
|     0      1      2      3      4                                 |
|                                                                   |
|o9 : Complex                                                       |
+-------------------------------------------------------------------+
|i10 : debugLevel = 1                                               |
|                                                                   |
|o10 = 1                                                            |
+-------------------------------------------------------------------+
|i11 : assert not isWellDefined D                                   |
|-- expected maps in the differential to compose to zero            |
|--   differentials at indices (2, 1) fail this condition           |
+-------------------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * isWellDefined(Complex) -- whether a
    complex is well-defined
  * complex(HashTable) -- make a chain complex
  * complex(List) -- make a chain complex

Ways to use this method:
========================

  * complex(ComplexMap) -- make a complex by
    specifying the differential

complex(HashTable) -- make a chain complex
******************************************

Synopsis
========

  * Function: complex,
  * Usage:
        complex H
  * Inputs:
      * H, a hash table (Macaulay2Doc), each key is an integer
        indexing a differential, and the value at that key is the map
  * Optional inputs (Macaulay2Doc),:
      * Base, => an integer (Macaulay2Doc), default
        value 0, ignored when the input is a hash table
  * Outputs:
      * a complex,

Description
===========

A complex is a sequence of objects (e.g. modules), connected by maps called
differentials.  The composition of any two consecutive maps is zero.

The same data type is used for both chain and cochain complexes.  If C is a
complex, then we have C^i = C_{-i}.

We construct the Koszul complex on the generators for the ideal of the twisted
cubic curve.

+-----------------------------------------------------+
|i1 : S = ZZ/101[a..d]                                |
|                                                     |
|o1 = S                                               |
|                                                     |
|o1 : PolynomialRing                                  |
+-----------------------------------------------------+
|i2 : I = ideal(b^2-a*c, b*c-a*d, c^2-b*d)            |
|                                                     |
|             2                    2                  |
|o2 = ideal (b  - a*c, b*c - a*d, c  - b*d)           |
|                                                     |
|o2 : Ideal of S                                      |
+-----------------------------------------------------+
|i3 : F1 = map(S^1,,matrix{{I_0, I_1, I_2}})          |
|                                                     |
|o3 = | b2-ac bc-ad c2-bd |                           |
|                                                     |
|             1       3                               |
|o3 : Matrix S  <--- S                                |
+-----------------------------------------------------+
|i4 : F2 = map(source F1,,matrix{                     |
|             {0, I_2, -I_1},                         |
|             {-I_2, 0, I_0},                         |
|             {I_1, -I_0, 0}                          |
|             })                                      |
|                                                     |
|o4 = {2} | 0      c2-bd  -bc+ad |                    |
|     {2} | -c2+bd 0      b2-ac  |                    |
|     {2} | bc-ad  -b2+ac 0      |                    |
|                                                     |
|             3       3                               |
|o4 : Matrix S  <--- S                                |
+-----------------------------------------------------+
|i5 : F3 = map(source F2,,matrix{{I_0}, {I_1}, {I_2}})|
|                                                     |
|o5 = {4} | b2-ac |                                   |
|     {4} | bc-ad |                                   |
|     {4} | c2-bd |                                   |
|                                                     |
|             3       1                               |
|o5 : Matrix S  <--- S                                |
+-----------------------------------------------------+
|i6 : C = complex hashTable{1 => F1, 2 => F2, 3 => F3}|
|                                                     |
|      1      3      3      1                         |
|o6 = S  <-- S  <-- S  <-- S                          |
|                                                     |
|     0      1      2      3                          |
|                                                     |
|o6 : Complex                                         |
+-----------------------------------------------------+
|i7 : isWellDefined C                                 |
|                                                     |
|o7 = true                                            |
+-----------------------------------------------------+

This is the primary constructor used by all of the more user friendly methods
for constructing a chain complex.

Caveat
======

This constructor minimizes computation and does very little error checking. To
verify that a complex is well constructed, use isWellDefined(Complex).

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * isWellDefined(Complex) -- whether a
    complex is well-defined
  * complex(List) -- make a chain complex
  * complex(Module) -- make a chain complex of
    length zero

Ways to use this method:
========================

  * complex(HashTable) -- make a chain complex

complex(Module) -- make a chain complex of length zero
******************************************************

Synopsis
========

  * Function: complex,
  * Usage:
        complex M
  * Inputs:
      * M, a module (Macaulay2Doc), or Ideal (Macaulay2Doc),
        or Ring (Macaulay2Doc).
  * Optional inputs (Macaulay2Doc),:
      * Base, => an integer (Macaulay2Doc), default
        value 0, index for M
  * Outputs:
      * a complex, returns the complex whose 0-th component is
        M.

Description
===========

In contrast to complex(HashTable), and
complex(List), this constructor provides a convenient method to
construct a complex with only one non-zero component.

We illustrate this with a free module.

+-----------------------+
|i1 : S = ZZ/101[a..d]  |
|                       |
|o1 = S                 |
|                       |
|o1 : PolynomialRing    |
+-----------------------+
|i2 : C0 = complex S^2  |
|                       |
|      2                |
|o2 = S                 |
|                       |
|     0                 |
|                       |
|o2 : Complex           |
+-----------------------+
|i3 : f = dd^C0         |
|                       |
|o3 = 0                 |
|                       |
|o3 : ComplexMap        |
+-----------------------+
|i4 : source f, target f|
|                       |
|       2   2           |
|o4 = (S , S )          |
|                       |
|      0   0            |
|                       |
|o4 : Sequence          |
+-----------------------+
|i5 : f == 0            |
|                       |
|o5 = true              |
+-----------------------+
|i6 : isWellDefined C0  |
|                       |
|o6 = true              |
+-----------------------+
|i7 : C0 == 0           |
|                       |
|o7 = false             |
+-----------------------+
|i8 : length C0         |
|                       |
|o8 = 0                 |
+-----------------------+
+-------------------------------+
|i9 : C1 = complex(S^2, Base=>3)|
|                               |
|      2                        |
|o9 = S                         |
|                               |
|     3                         |
|                               |
|o9 : Complex                   |
+-------------------------------+
|i10 : C1 == C0[-3]             |
|                               |
|o10 = true                     |
+-------------------------------+
|i11 : C1_3                     |
|                               |
|       2                       |
|o11 = S                        |
|                               |
|o11 : S-module, free           |
+-------------------------------+
|i12 : C1_0                     |
|                               |
|o12 = 0                        |
|                               |
|o12 : S-module                 |
+-------------------------------+

A ring or an ideal will be converted to a module first.

+---------------------------+
|i13 : C2 = complex S       |
|                           |
|       1                   |
|o13 = S                    |
|                           |
|      0                    |
|                           |
|o13 : Complex              |
+---------------------------+
|i14 : I = ideal(a^2-b, c^3)|
|                           |
|              2       3    |
|o14 = ideal (a  - b, c )   |
|                           |
|o14 : Ideal of S           |
+---------------------------+
|i15 : C3 = complex I       |
|                           |
|o15 = image | a2-b c3 |    |
|                           |
|      0                    |
|                           |
|o15 : Complex              |
+---------------------------+
|i16 : C4 = complex (S/I)   |
|                           |
|      /      S     \1      |
|o16 = |------------|       |
|      |  2       3 |       |
|      \(a  - b, c )/       |
|                           |
|      0                    |
|                           |
|o16 : Complex              |
+---------------------------+
|i17 : (ring C3, ring C4)   |
|                           |
|                S          |
|o17 = (S, ------------)    |
|            2       3      |
|          (a  - b, c )     |
|                           |
|o17 : Sequence             |
+---------------------------+

The zero complex over a ring S is most conveniently created by giving the zero
module.

+----------------------+
|i18 : C5 = complex S^0|
|                      |
|o18 = 0               |
|                      |
|      0               |
|                      |
|o18 : Complex         |
+----------------------+
|i19 : C5 == 0         |
|                      |
|o19 = true            |
+----------------------+
|i20 : dd^C5 == 0      |
|                      |
|o20 = true            |
+----------------------+
|i21 : C5_0            |
|                      |
|o21 = 0               |
|                      |
|o21 : S-module        |
+----------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * isWellDefined(Complex) -- whether a
    complex is well-defined
  * complex(HashTable) -- make a chain complex

Ways to use this method:
========================

  * "complex(Ideal)"
  * complex(Module) -- make a chain complex of
    length zero
  * "complex(Ring)"

ComplexMap -- the class of all maps between chain complexes
***********************************************************

Description
===========

A map of chain complexes $f \colon C \rightarrow D$ of degree $d$ is a sequence
of maps $f_i \colon C_i \rightarrow D_{d+i}$. No relationship between the maps
$f_i$ and and the differentials of either $C$ or $D$ is assumed.

The set of all maps from $C$ to $D$ form the complex $\Hom(C,D)$ where
$\Hom(C,D)_d$ consists of the maps of degree $d$.

The usual algebraic operations are available: addition, subtraction, scalar
multiplication, and composition. The identity map from a chain complex to
itself can be produced with id (Macaulay2Doc). An attempt to add
(subtract, or compare) a ring element to a chain complex will result in the
ring element being multiplied by the appropriate identity map.

See also
========

  * Complex -- the class of all chain complexes

Functions and methods returning a map of complexes :
====================================================

  * "ComplexMap + Number" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex maps
  * "ComplexMap + RingElement" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex
    maps
  * "ComplexMap - ComplexMap" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex
    maps
  * "ComplexMap - Number" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex maps
  * "ComplexMap - RingElement" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex
    maps
  * "Number + ComplexMap" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex maps
  * "Number - ComplexMap" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex maps
  * "RingElement + ComplexMap" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex
    maps
  * "RingElement - ComplexMap" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex
    maps
  * "augmentationMap(Complex)" -- see augmentationMap,
    -- map from a free resolution to a module regarded as a complex
  * "canonicalMap(Complex,Complex)" -- see canonicalMap, --
    gets the natural map arising from various constructions
  * "canonicalTruncation(ComplexMap,InfiniteNumber,InfiniteNumber)" -- see
    canonicalTruncation(ComplexMap,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * "canonicalTruncation(ComplexMap,InfiniteNumber,ZZ)" -- see
    canonicalTruncation(ComplexMap,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * "canonicalTruncation(ComplexMap,Nothing,ZZ)" -- see
    canonicalTruncation(ComplexMap,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * "canonicalTruncation(ComplexMap,Sequence)" -- see
    canonicalTruncation(ComplexMap,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * "canonicalTruncation(ComplexMap,ZZ,InfiniteNumber)" -- see
    canonicalTruncation(ComplexMap,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * "canonicalTruncation(ComplexMap,ZZ,Nothing)" -- see
    canonicalTruncation(ComplexMap,ZZ,ZZ),
    -- reducing the number of
    non-zero terms of a complex
  * canonicalTruncation(ComplexMap,ZZ,ZZ)
    -- reducing the number of
    non-zero terms of a complex
  * Complex ** Matrix -- create the tensor
    product of a complex and a map of modules
  * "Matrix ** Complex" -- see Complex ** Matrix,
    -- create the tensor product of a complex and a map of modules
  * "Complex ^ Array" -- see Complex _ Array, -- the
    canonical inclusion or projection map of a direct sum
  * Complex _ Array -- the canonical inclusion or
    projection map of a direct sum
  * "ComplexMap Array" -- see Complex Array, -- shift a
    complex or complex map
  * complex(ChainComplexMap) -- translate
    between data types for chain complex maps
  * "Complex ** ComplexMap" -- see ComplexMap ** ComplexMap,
    -- the map of complexes between tensor complexes
  * "ComplexMap ** Complex" -- see ComplexMap ** ComplexMap,
    -- the map of complexes between tensor complexes
  * ComplexMap ** ComplexMap -- the map of
    complexes between tensor complexes
  * "ComplexMap ** Module" -- see ComplexMap ** ComplexMap,
    -- the map of complexes between tensor complexes
  * "Module ** ComplexMap" -- see ComplexMap ** ComplexMap,
    -- the map of complexes between tensor complexes
  * "tensor(ComplexMap,ComplexMap)" -- see ComplexMap ** ComplexMap,
    -- the map of complexes between tensor
    complexes
  * ComplexMap ++ ComplexMap -- direct sum of
    complex maps
  * ComplexMap ^ Array -- the composition with the
    canonical inclusion or projection map
  * "ComplexMap _ Array" -- see ComplexMap ^ Array,
    -- the composition with the canonical inclusion or projection map
  * ComplexMap ^ ZZ -- the n-fold composition
  * ComplexMap | ComplexMap -- join or
    concatenate maps horizontally
  * ComplexMap || ComplexMap -- join or
    concatenate maps vertically
  * "connectingExtMap(Matrix,Matrix,Module)" -- see
    connectingExtMap(Module,Matrix,Matrix),
    -- makes the connecting
    maps in Ext
  * connectingExtMap(Module,Matrix,Matrix)
    -- makes the connecting
    maps in Ext
  * connectingMap(ComplexMap,ComplexMap)
    -- construct the connecting
    homomorphism on homology
  * "connectingTorMap(Matrix,Matrix,Module)" -- see
    connectingTorMap(Module,Matrix,Matrix),
    -- makes the connecting
    maps in Tor
  * connectingTorMap(Module,Matrix,Matrix)
    -- makes the connecting
    maps in Tor
  * "Symbol ^ Complex" -- see differential of a chain complex,
    -- get the maps between the terms in a
    complex
  * dual(ComplexMap) -- the dual of a map of
    complexes
  * "extend(Complex,Complex,Matrix)" -- see
    extend(Complex,Complex,Matrix,Sequence),
    -- extend a map of
    modules to a map of chain complexes
  * extend(Complex,Complex,Matrix,Sequence)
    -- extend a map of
    modules to a map of chain complexes
  * freeResolution(Matrix) -- compute the
    induced map between free resolutions
  * HH ComplexMap -- induced map on homology or
    cohomology
  * "Hom(Complex,ComplexMap)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(Complex,Matrix)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(ComplexMap,Complex)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * Hom(ComplexMap,ComplexMap) -- the
    map of complexes between Hom complexes
  * "Hom(ComplexMap,Matrix)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(ComplexMap,Module)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(ComplexMap,Ring)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(Matrix,Complex)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(Matrix,ComplexMap)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(Module,ComplexMap)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * "Hom(Ring,ComplexMap)" -- see Hom(ComplexMap,ComplexMap),
    -- the map of complexes between Hom
    complexes
  * homomorphism'(ComplexMap) -- get the
    element of Hom from a map of complexes
  * homomorphism(ComplexMap) -- get the
    homomorphism from an element of Hom
  * homomorphism(ZZ,Matrix,Complex)
    -- get the homomorphism from an
    element of Hom
  * inducedMap(Complex,Complex), --
    make the map of complexes induced at each term by the identity map
  * "homotopyMap(ComplexMap)" -- see
    liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap),
    -- lift a map of
    chain complexes along a quasi-isomorphism
  * map(Complex,Complex,ComplexMap)
    -- make a new map of chain
    complexes from an existing one
  * map(Complex,Complex,Function),
    -- make a map of chain complexes
  * map(Complex,Complex,HashTable)
    -- make a map of chain complexes
  * map(Complex,Complex,List) -- make
    a map of chain complexes
  * map(Complex,Complex,ZZ) -- make the
    zero map or identity between chain complexes
  * "minimalPresentation(ComplexMap)" -- see
    minimalPresentation(Complex), -- minimal
    presentation of all terms in a complex
  * "prune(ComplexMap)" -- see minimalPresentation(Complex),
    -- minimal presentation of all terms in a
    complex
  * "naiveTruncation(ComplexMap,InfiniteNumber,InfiniteNumber)" -- see
    naiveTruncation(ComplexMap,ZZ,ZZ),
    -- drops all terms in the source
    of a complex outside a given interval
  * "naiveTruncation(ComplexMap,InfiniteNumber,ZZ)" -- see
    naiveTruncation(ComplexMap,ZZ,ZZ),
    -- drops all terms in the source
    of a complex outside a given interval
  * "naiveTruncation(ComplexMap,Nothing,ZZ)" -- see
    naiveTruncation(ComplexMap,ZZ,ZZ),
    -- drops all terms in the source
    of a complex outside a given interval
  * "naiveTruncation(ComplexMap,Sequence)" -- see
    naiveTruncation(ComplexMap,ZZ,ZZ),
    -- drops all terms in the source
    of a complex outside a given interval
  * "naiveTruncation(ComplexMap,Sequence,Sequence)" -- see
    naiveTruncation(ComplexMap,ZZ,ZZ),
    -- drops all terms in the source
    of a complex outside a given interval
  * "naiveTruncation(ComplexMap,ZZ,InfiniteNumber)" -- see
    naiveTruncation(ComplexMap,ZZ,ZZ),
    -- drops all terms in the source
    of a complex outside a given interval
  * "naiveTruncation(ComplexMap,ZZ,Nothing)" -- see
    naiveTruncation(ComplexMap,ZZ,ZZ),
    -- drops all terms in the source
    of a complex outside a given interval
  * naiveTruncation(ComplexMap,ZZ,ZZ)
    -- drops all terms in the source
    of a complex outside a given interval
  * nullHomotopy(ComplexMap) -- a map
    which is a candidate for being a null homotopy
  * part(List,ComplexMap) -- extract a
    graded component of a map of complexes
  * "part(ZZ,ComplexMap)" -- see part(List,ComplexMap),
    -- extract a graded component of a map of
    complexes
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes
  * "resolutionMap(Complex)" -- see resolutionMap, -- map
    from a free resolution to the given complex
  * "ComplexMap ** Ring" -- see RingMap ** ComplexMap,
    -- tensor a map of complexes along a ring map
  * "ComplexMap ** RingMap" -- see RingMap ** ComplexMap,
    -- tensor a map of complexes along a ring map
  * "Ring ** ComplexMap" -- see RingMap ** ComplexMap,
    -- tensor a map of complexes along a ring map
  * RingMap ** ComplexMap -- tensor a map of
    complexes along a ring map
  * "tensor(ComplexMap,RingMap)" -- see RingMap ** ComplexMap,
    -- tensor a map of complexes along a ring map
  * "tensor(RingMap,ComplexMap)" -- see RingMap ** ComplexMap,
    -- tensor a map of complexes along a ring map
  * RingMap ComplexMap -- apply a ring map to a map
    of complexes
  * tensorAssociativity(Complex,Complex,Complex)
    -- make the canonical
    isomorphism arising from associativity
  * tensorCommutativity(Complex,Complex)
    -- make the canonical
    isomorphism arising from commutativity
  * truncate(List,ComplexMap), --
    truncation of a complex map at a specified degree or set of degrees
  * "truncate(ZZ,ComplexMap)" -- see truncate(List,ComplexMap),
    -- truncation of a complex map at a
    specified degree or set of degrees
  * yonedaMap(Matrix) -- creates a chain complex
    map representing an extension of modules

Methods that use a map of complexes :
=====================================

  * "- ComplexMap" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex maps
  * "ComplexMap * Number" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex maps
  * "ComplexMap * RingElement" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex
    maps
  * "ComplexMap + ComplexMap" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex
    maps
  * "Number * ComplexMap" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex maps
  * "RingElement * ComplexMap" -- see arithmetic with complex maps,
    -- perform arithmetic operations on complex
    maps
  * chainComplex(ComplexMap) -- translate
    between data types for chain complexes
  * coimage(ComplexMap) -- make the coimage of
    a map of complexes
  * cokernel(ComplexMap) -- make the cokernel
    of a map of complexes
  * complex(ComplexMap) -- make a complex by
    specifying the differential
  * ComplexMap * ComplexMap -- composition of
    homomorphisms of complexes
  * "directSum(ComplexMap)" -- see ComplexMap ++ ComplexMap,
    -- direct sum of complex maps
  * ComplexMap == ComplexMap -- whether two
    complex maps are equal
  * "ComplexMap == ZZ" -- see ComplexMap == ComplexMap,
    -- whether two complex maps are equal
  * "ZZ == ComplexMap" -- see ComplexMap == ComplexMap,
    -- whether two complex maps are equal
  * ComplexMap _ ZZ -- access individual matrices in
    a complex map
  * components(ComplexMap) -- list the
    components of a direct sum
  * concentration(ComplexMap) -- indices
    on which a complex map may be non-zero
  * cone(ComplexMap) -- make the mapping cone of a
    morphism of chain complexes
  * "cylinder(ComplexMap)" -- see cylinder, -- make the mapping
    cylinder of a morphism of chain complexes
  * degree(ComplexMap) -- get the degree of a
    map of chain complexes
  * "HH^ZZ ComplexMap" -- see HH ComplexMap, -- induced
    map on homology or cohomology
  * "HH_ZZ ComplexMap" -- see HH ComplexMap, -- induced
    map on homology or cohomology
  * image(ComplexMap) -- make the image of a map
    of complexes
  * isCommutative(ComplexMap) -- whether
    a complex map commutes with the differentials
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes
  * isHomogeneous(ComplexMap) -- whether
    a map of complexes is homogeneous
  * isNullHomotopic(ComplexMap), --
    whether a map of complexes is null-homotopic
  * isNullHomotopyOf(ComplexMap,ComplexMap)
    -- whether the first map of
    chain complexes is a null homotopy for the second
  * isQuasiIsomorphism(ComplexMap),
    -- whether a map of complexes is a quasi-isomorphism
  * isShortExactSequence(ComplexMap,ComplexMap)
    -- whether a pair of
    complex maps forms a short exact sequence
  * isWellDefined(ComplexMap) -- whether
    a map of chain complexes is well-defined
  * kernel(ComplexMap) -- make the kernel of a
    map of complexes
  * "ComplexMap // ComplexMap" -- see
    liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap),
    -- lift a map of
    chain complexes along a quasi-isomorphism
  * liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap)
    -- lift a map of
    chain complexes along a quasi-isomorphism
  * "quotient(ComplexMap,ComplexMap)" -- see
    liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap),
    -- lift a map of
    chain complexes along a quasi-isomorphism
  * longExactSequence(ComplexMap,ComplexMap)
    -- make the long exact
    sequence in homology
  * "ring(ComplexMap)" -- see ring(Complex), -- access
    the ring of a complex or a complex map
  * source(ComplexMap) -- get the source of a
    map of chain complexes
  * "sum(ComplexMap)" -- see sum(Complex), -- make the
    direct sum of all terms
  * target(ComplexMap) -- get the target of a
    map of chain complexes
  * yonedaMap'(ComplexMap) -- identifies the
    element of Ext corresponding to a map of free resolutions

For the programmer
==================

The object ComplexMap, is a type (Macaulay2Doc),
with ancestor classes HashTable (Macaulay2Doc), < Thing (Macaulay2Doc).

ComplexMap * ComplexMap -- composition of homomorphisms of complexes
********************************************************************

Synopsis
========

  * Operator: * (Macaulay2Doc),
  * Usage:
        f = h * g
  * Inputs:
      * h, a map of complexes, if a ring element or integer,
        then we multiply the ring element by the appropriate identity map
      * g, a map of complexes,
  * Outputs:
      * f, a map of complexes, the composition of $g$
        followed by $h$

Description
===========

If $g_i : C_i \rightarrow D_{d+i}$, and $h_j : D_j \rightarrow E_{e+j}$, then
the composition corresponds to $f_i := h_{d+i} * g_i : C_i \rightarrow
E_{i+d+e}$.  In particular, the degree of the composition $f$ is the sum of the
degrees of $g$ and $h$.

+-------------------------------------------------------+
|i1 : R = ZZ/101[a..d]                                  |
|                                                       |
|o1 = R                                                 |
|                                                       |
|o1 : PolynomialRing                                    |
+-------------------------------------------------------+
|i2 : C = freeResolution coker vars R                   |
|                                                       |
|      1      4      6      4      1                    |
|o2 = R  <-- R  <-- R  <-- R  <-- R                     |
|                                                       |
|     0      1      2      3      4                     |
|                                                       |
|o2 : Complex                                           |
+-------------------------------------------------------+
|i3 : 3 * dd^C                                          |
|                                                       |
|          1                       4                    |
|o3 = 0 : R  <------------------- R  : 1                |
|               | 3a 3b 3c 3d |                         |
|                                                       |
|          4                                       6    |
|     1 : R  <----------------------------------- R  : 2|
|               {1} | -3b -3c 0   -3d 0   0   |         |
|               {1} | 3a  0   -3c 0   -3d 0   |         |
|               {1} | 0   3a  3b  0   0   -3d |         |
|               {1} | 0   0   0   3a  3b  3c  |         |
|                                                       |
|          6                               4            |
|     2 : R  <--------------------------- R  : 3        |
|               {2} | 3c  3d  0   0   |                 |
|               {2} | -3b 0   3d  0   |                 |
|               {2} | 3a  0   0   3d  |                 |
|               {2} | 0   -3b -3c 0   |                 |
|               {2} | 0   3a  0   -3c |                 |
|               {2} | 0   0   3a  3b  |                 |
|                                                       |
|          4                   1                        |
|     3 : R  <--------------- R  : 4                    |
|               {3} | -3d |                             |
|               {3} | 3c  |                             |
|               {3} | -3b |                             |
|               {3} | 3a  |                             |
|                                                       |
|o3 : ComplexMap                                        |
+-------------------------------------------------------+
|i4 : 0 * dd^C                                          |
|                                                       |
|o4 = 0                                                 |
|                                                       |
|o4 : ComplexMap                                        |
+-------------------------------------------------------+
|i5 : dd^C * dd^C                                       |
|                                                       |
|o5 = 0                                                 |
|                                                       |
|o5 : ComplexMap                                        |
+-------------------------------------------------------+

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * arithmetic with complex maps, --
    perform arithmetic operations on complex maps

Ways to use this method:
========================

  * ComplexMap * ComplexMap -- composition of
    homomorphisms of complexes

ComplexMap ** ComplexMap -- the map of complexes between tensor complexes
*************************************************************************

Synopsis
========

  * Operator: ** (Macaulay2Doc),
  * Usage:
        h = f ** g
        h = tensor(f, g)
  * Inputs:
      * f, a map of complexes,
      * g, a map of complexes,
  * Outputs:
      * h, a map of complexes,

Description
===========

The maps $f : C \to D$ and $g : E \to F$ of chain complexes induces the map $h
= f \otimes g : C \otimes E \to D \otimes F$ defined by $c \otimes e \mapsto
f(c) \otimes g(e)$.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..c]                                                        |
|                                                                             |
|o1 = S                                                                       |
|                                                                             |
|o1 : PolynomialRing                                                          |
+-----------------------------------------------------------------------------+
|i2 : C = freeResolution coker vars S                                         |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : D = (freeResolution coker matrix{{a^2,a*b,b^3}})[-1]                    |
|                                                                             |
|      1      3      2                                                        |
|o3 = S  <-- S  <-- S                                                         |
|                                                                             |
|     1      2      3                                                         |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : f = randomComplexMap(D,C)                                               |
|                                                                             |
|                   1                                                         |
|o4 = 0 : 0 <----- S  : 0                                                     |
|              0                                                              |
|                                                                             |
|          1                                                3                 |
|     1 : S  <-------------------------------------------- S  : 1             |
|               | 24a-36b-30c -29a+19b+19c -10a-29b-8c |                      |
|                                                                             |
|          3                           3                                      |
|     2 : S  <----------------------- S  : 2                                  |
|               {2} | -22 -24 -16 |                                           |
|               {2} | -29 -38 39  |                                           |
|               {3} | 0   0   0   |                                           |
|                                                                             |
|          2                  1                                               |
|     3 : S  <-------------- S  : 3                                           |
|               {3} | 21 |                                                    |
|               {4} | 0  |                                                    |
|                                                                             |
|o4 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i5 : E = (dual C)[-3]                                                        |
|                                                                             |
|      1      3      3      1                                                 |
|o5 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o5 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i6 : F = (dual D)[-3]                                                        |
|                                                                             |
|      2      3      1                                                        |
|o6 = S  <-- S  <-- S                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o6 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i7 : g = randomComplexMap(F,E)                                               |
|                                                                             |
|          2                            1                                     |
|o7 = 0 : S  <------------------------ S  : 0                                 |
|               {-3} | 34          |                                          |
|               {-4} | 19a-47b-39c |                                          |
|                                                                             |
|          3                                                     3            |
|     1 : S  <------------------------------------------------- S  : 1        |
|               {-2} | -18          -47        45           |                 |
|               {-2} | -13          38         -34          |                 |
|               {-3} | -43a-15b-28c 2a+16b+22c -48a-47b+47c |                 |
|                                                                             |
|          1         3                                                        |
|     2 : S  <----- S  : 2                                                    |
|               0                                                             |
|                                                                             |
|                   1                                                         |
|     3 : 0 <----- S  : 3                                                     |
|              0                                                              |
|                                                                             |
|o7 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i8 : h = f ** g                                                              |
|                                                                             |
|                   1                                                         |
|o8 = 0 : 0 <----- S  : 0                                                     |
|              0                                                              |
|                                                                             |
|          2                                                                  |
|     1 : S  <----------------------------------------------------------------|
|               {-3} | 0 0 0 8a-12b-10c                   24a+40b+40c         |
|               {-4} | 0 0 0 -49a2+6ab-25b2+9ac-14bc-42c2 -46a2+7ab+16b2-23ac-|
|                                                                             |
|          9                                                                  |
|     2 : S  <----------------------------------------------------------------|
|               {-2} | 0 0 0 -28a+42b+35c                   -17a-25b-4c       |
|               {-2} | 0 0 0 -9a-37b-14c                    3a+46b-29c        |
|               {-3} | 0 0 0 -22a2-24ab+35b2+12ac+44bc+32c2 48a2+9ab+30b2-37ac|
|               {-1} | 0 0 0 0                              0                 |
|               {-2} | 0 0 0 0                              0                 |
|               {-1} | 0 0 0 0                              0                 |
|               {-2} | 0 0 0 0                              0                 |
|               {0}  | 0 0 0 0                              0                 |
|               {-1} | 0 0 0 0                              0                 |
|                                                                             |
|          14                                                                 |
|     3 : S   <---------------------------------------------------------------|
|                {0}  | 0 0 0 0 0 0 0 0 0 0 0           0            0        |
|                {0}  | 0 0 0 0 0 0 0 0 0 0 -8          24           20       |
|                {0}  | 0 0 0 0 0 0 0 0 0 0 -17         -28          41       |
|                {-1} | 0 0 0 0 0 0 0 0 0 0 37a+27b+10c -44a-49b+21c 46a+24b-2|
|                {0}  | 0 0 0 0 0 0 0 0 0 0 17          50           8        |
|                {0}  | 0 0 0 0 0 0 0 0 0 0 -27         9            -24      |
|                {-1} | 0 0 0 0 0 0 0 0 0 0 35a+31b+4c  43a+41b-32c  -22a+50b-|
|                {1}  | 0 0 0 0 0 0 0 0 0 0 0           0            0        |
|                {1}  | 0 0 0 0 0 0 0 0 0 0 0           0            0        |
|                {0}  | 0 0 0 0 0 0 0 0 0 0 0           0            0        |
|                {0}  | 0 0 0 0 0 0 0 0 0 0 0           0            0        |
|                {-1} | 0 0 0 0 0 0 0 0 0 0 0           0            0        |
|                {1}  | 0 0 0 0 0 0 0 0 0 0 0           0            0        |
|                {0}  | 0 0 0 0 0 0 0 0 0 0 0           0            0        |
|                                                                             |
|          9                                                                  |
|     4 : S  <----------------------------------------------------------------|
|               {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0          0           0        |
|               {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0          0           0        |
|               {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0          0           0        |
|               {1} | 0 0 0 0 0 0 0 0 0 0 0 0 26         23          36       |
|               {1} | 0 0 0 0 0 0 0 0 0 0 0 0 30         -10         -7       |
|               {0} | 0 0 0 0 0 0 0 0 0 0 0 0 6a-12b+18c 42a+33b-43c 2a+23b-23|
|               {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0          0           0        |
|               {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0          0           0        |
|               {1} | 0 0 0 0 0 0 0 0 0 0 0 0 0          0           0        |
|                                                                             |
|          2         6                                                        |
|     5 : S  <----- S  : 5                                                    |
|               0                                                             |
|                                                                             |
|                   1                                                         |
|     6 : 0 <----- S  : 6                                                     |
|              0                                                              |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                           6                                 |
|----------------------------------------- S  : 1                             |
|          -37a+24b+31c                |                                      |
|18bc-34c2 12a2+20ab+50b2+36ac-8bc+9c2 |                                      |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|           -31a-4b-37c                  17a-39b-39c                 50a+16b+1|
|           -8a+12b+10c                  -27a-45b-45c                9a+15b+15|
|+41bc+47c2 -41a2-6ab-25b2+43ac+21bc+4c2 35a2+22ab+18b2-5ac-9bc-27c2 43a2-22ab|
|           0                            0                           0        |
|           0                            0                           0        |
|           0                            0                           0        |
|           0                            0                           0        |
|           0                            0                           0        |
|           0                            0                           0        |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|    0           0            0           0            0            0         |
|    28          17           31          -15          45           -13       |
|    9           -3           8           6            -2           39        |
|4c  22a-44b-35c -48a+20b-23c 41a+17b-17c -19a+38b+44c -32a+47b-49c -40a+45b-4|
|    -23         -32          7           5            -15          38        |
|    -11         -30          -21         -2           -33          -13       |
|50c 18a-36b-47c 25a-2b-28c   6a-32b+32c  40a+21b+19c  -23a+18b+50c 47a-15b+15|
|    0           0            0           0            0            0         |
|    0           0            0           0            0            0         |
|    0           0            0           0            0            0         |
|    0           0            0           0            0            0         |
|    0           0            0           0            0            0         |
|    0           0            0           0            0            0         |
|    0           0            0           0            0            0         |
|                                                                             |
|       15                                                                    |
|----- S   : 4                                                                |
|  |                                                                          |
|  |                                                                          |
|  |                                                                          |
|  |                                                                          |
|  |                                                                          |
|c |                                                                          |
|  |                                                                          |
|  |                                                                          |
|  |                                                                          |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|6c                8a+47b+47c                -22a+17b+43c                  -35|
|c                 -24a-40b-40c              29a-27b+3c                    24a|
|+b2+6ac+15bc+14c2 -22a2+47ab+16b2+48ac-16c2 26a2-17ab+31b2+18ac+23bc+22c2 -20|
|                  0                         0                             0  |
|                  0                         0                             0  |
|                  0                         0                             0  |
|                  0                         0                             0  |
|                  0                         0                             0  |
|                  0                         0                             0  |
|                                                                             |
|                    20                                                       |
|------------------ S   : 3                                                   |
|   0           |                                                             |
|   0           |                                                             |
|   0           |                                                             |
|5c 0           |                                                             |
|   0           |                                                             |
|   0           |                                                             |
|c  0           |                                                             |
|   0           |                                                             |
|   0           |                                                             |
|   0           |                                                             |
|   7           |                                                             |
|   -5a+23b-11c |                                                             |
|   0           |                                                             |
|   0           |                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|a+50b-28c                   -46a+8b+44c                    0            0    |
|+9b-c                       37a-24b-31c                    0            0    |
|a2-16ab+41b2-34ac+42bc+26c2 -25a2+44ab+50b2+15ac+23bc+28c2 0            0    |
|                            0                              -41          -8   |
|                            0                              -14a+24b+50c 49a+1|
|                            0                              24           21   |
|                            0                              -46a+50b+20c -15a-|
|                            0                              0            0    |
|                            0                              0            0    |
|-----------------------------------------------------------------------------|
|                        15                                                   |
|---------------------- S   : 2                                               |
|        0          |                                                         |
|        0          |                                                         |
|        0          |                                                         |
|        -39        |                                                         |
|7b+27c  -a+45b+18c |                                                         |
|        13         |                                                         |
|32b-33c 34a-15b-6c |                                                         |
|        0          |                                                         |
|        0          |                                                         |
+-----------------------------------------------------------------------------+
|i9 : assert isWellDefined h                                                  |
+-----------------------------------------------------------------------------+
|i10 : assert(source h === C ** E)                                            |
+-----------------------------------------------------------------------------+
|i11 : assert(target h === D ** F)                                            |
+-----------------------------------------------------------------------------+

If one argument is a Complex or Module, then the identity map of the
corresponding complex is used.

+-----------------------------------------------------------------------------+
|i12 : fE = f ** E                                                            |
|                                                                             |
|                    1                                                        |
|o12 = 0 : 0 <----- S  : 0                                                    |
|               0                                                             |
|                                                                             |
|           1                                                           6     |
|      1 : S  <------------------------------------------------------- S  : 1 |
|                {-3} | 0 0 0 24a-36b-30c -29a+19b+19c -10a-29b-8c |          |
|                                                                             |
|           6                                                                 |
|      2 : S  <---------------------------------------------------------------|
|                {-2} | 0 0 0 24a-36b-30c 0           0           -29a+19b+19c|
|                {-2} | 0 0 0 0           24a-36b-30c 0           0           |
|                {-2} | 0 0 0 0           0           24a-36b-30c 0           |
|                {-1} | 0 0 0 0           0           0           0           |
|                {-1} | 0 0 0 0           0           0           0           |
|                {0}  | 0 0 0 0           0           0           0           |
|                                                                             |
|           14                                                                |
|      3 : S   <--------------------------------------------------------------|
|                 {-1} | 0 24a-36b-30c 0           0           -29a+19b+19c 0 |
|                 {-1} | 0 0           24a-36b-30c 0           0            -2|
|                 {-1} | 0 0           0           24a-36b-30c 0            0 |
|                 {0}  | 0 0           0           0           0            0 |
|                 {0}  | 0 0           0           0           0            0 |
|                 {0}  | 0 0           0           0           0            0 |
|                 {0}  | 0 0           0           0           0            0 |
|                 {0}  | 0 0           0           0           0            0 |
|                 {0}  | 0 0           0           0           0            0 |
|                 {1}  | 0 0           0           0           0            0 |
|                 {1}  | 0 0           0           0           0            0 |
|                 {1}  | 0 0           0           0           0            0 |
|                 {0}  | 0 0           0           0           0            0 |
|                 {1}  | 0 0           0           0           0            0 |
|                                                                             |
|           16                                                                |
|      4 : S   <--------------------------------------------------------------|
|                 {0} | 24a-36b-30c -29a+19b+19c -10a-29b-8c 0   0   0   0   0|
|                 {1} | 0           0            0           -22 0   0   -24 0|
|                 {1} | 0           0            0           0   -22 0   0   -|
|                 {1} | 0           0            0           0   0   -22 0   0|
|                 {1} | 0           0            0           -29 0   0   -38 0|
|                 {1} | 0           0            0           0   -29 0   0   -|
|                 {1} | 0           0            0           0   0   -29 0   0|
|                 {2} | 0           0            0           0   0   0   0   0|
|                 {2} | 0           0            0           0   0   0   0   0|
|                 {2} | 0           0            0           0   0   0   0   0|
|                 {1} | 0           0            0           0   0   0   0   0|
|                 {1} | 0           0            0           0   0   0   0   0|
|                 {1} | 0           0            0           0   0   0   0   0|
|                 {2} | 0           0            0           0   0   0   0   0|
|                 {2} | 0           0            0           0   0   0   0   0|
|                 {2} | 0           0            0           0   0   0   0   0|
|                                                                             |
|           9                                    6                            |
|      5 : S  <-------------------------------- S  : 5                        |
|                {2} | -22 -24 -16 0  0  0  |                                 |
|                {2} | -29 -38 39  0  0  0  |                                 |
|                {3} | 0   0   0   0  0  0  |                                 |
|                {2} | 0   0   0   21 0  0  |                                 |
|                {2} | 0   0   0   0  21 0  |                                 |
|                {2} | 0   0   0   0  0  21 |                                 |
|                {3} | 0   0   0   0  0  0  |                                 |
|                {3} | 0   0   0   0  0  0  |                                 |
|                {3} | 0   0   0   0  0  0  |                                 |
|                                                                             |
|           2                  1                                              |
|      6 : S  <-------------- S  : 6                                          |
|                {3} | 21 |                                                   |
|                {4} | 0  |                                                   |
|                                                                             |
|o12 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
| 0            0            -10a-29b-8c 0           0           0   0   0   | |
| -29a+19b+19c 0            0           -10a-29b-8c 0           0   0   0   | |
| 0            -29a+19b+19c 0           0           -10a-29b-8c 0   0   0   | |
| 0            0            0           0           0           -22 -24 -16 | |
| 0            0            0           0           0           -29 -38 39  | |
| 0            0            0           0           0           0   0   0   | |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|           0            -10a-29b-8c 0           0           0   0   0   0   0|
|9a+19b+19c 0            0           -10a-29b-8c 0           0   0   0   0   0|
|           -29a+19b+19c 0           0           -10a-29b-8c 0   0   0   0   0|
|           0            0           0           0           -22 0   0   -24 0|
|           0            0           0           0           0   -22 0   0   -|
|           0            0           0           0           0   0   -22 0   0|
|           0            0           0           0           -29 0   0   -38 0|
|           0            0           0           0           0   -29 0   0   -|
|           0            0           0           0           0   0   -29 0   0|
|           0            0           0           0           0   0   0   0   0|
|           0            0           0           0           0   0   0   0   0|
|           0            0           0           0           0   0   0   0   0|
|           0            0           0           0           0   0   0   0   0|
|           0            0           0           0           0   0   0   0   0|
|                                                                             |
|                                 15                                          |
|------------------------------- S   : 4                                      |
|   0   0   0   0   0  0  0  |                                                |
|   0   -16 0   0   0  0  0  |                                                |
|24 0   0   -16 0   0  0  0  |                                                |
|   -24 0   0   -16 0  0  0  |                                                |
|   0   39  0   0   0  0  0  |                                                |
|38 0   0   39  0   0  0  0  |                                                |
|   -38 0   0   39  0  0  0  |                                                |
|   0   0   0   0   0  0  0  |                                                |
|   0   0   0   0   0  0  0  |                                                |
|   0   0   0   0   0  0  0  |                                                |
|   0   0   0   0   21 0  0  |                                                |
|   0   0   0   0   0  21 0  |                                                |
|   0   0   0   0   0  0  21 |                                                |
|   0   0   0   0   0  0  0  |                                                |
|   0   0   0   0   0  0  0  |                                                |
|   0   0   0   0   0  0  0  |                                                |
|-----------------------------------------------------------------------------|
|   15                                                                        |
|- S   : 2                                                                    |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                           20                                                |
|------------------------- S   : 3                                            |
|   0   0   0   0   0  |                                                      |
|   0   0   0   0   0  |                                                      |
|   0   0   0   0   0  |                                                      |
|   0   -16 0   0   0  |                                                      |
|24 0   0   -16 0   0  |                                                      |
|   -24 0   0   -16 0  |                                                      |
|   0   39  0   0   0  |                                                      |
|38 0   0   39  0   0  |                                                      |
|   -38 0   0   39  0  |                                                      |
|   0   0   0   0   0  |                                                      |
|   0   0   0   0   0  |                                                      |
|   0   0   0   0   0  |                                                      |
|   0   0   0   0   21 |                                                      |
|   0   0   0   0   0  |                                                      |
+-----------------------------------------------------------------------------+
|i13 : assert(fE === f ** id_E)                                               |
+-----------------------------------------------------------------------------+
|i14 : k = coker vars S                                                       |
|                                                                             |
|o14 = cokernel | a b c |                                                     |
|                                                                             |
|                             1                                               |
|o14 : S-module, quotient of S                                                |
+-----------------------------------------------------------------------------+
|i15 : gk = g ** k                                                            |
|                                                                             |
|o15 = 0 : cokernel {-3} | a b c 0 0                                          |
|                   {-4} | 0 0 0 a b                                          |
|                                                                             |
|                                                                             |
|      1 : cokernel {-2} | a b c 0 0                                          |
|                   {-2} | 0 0 0 a b                                          |
|                   {-3} | 0 0 0 0 0                                          |
|                                                                             |
|                                                                             |
|      2 : cokernel | a b c | <-----                                          |
|                                0                                            |
|                                                                             |
|                                                                             |
|      3 : 0 <----- cokernel | a b c                                          |
|               0                                                             |
|                                                                             |
|o15 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|0 | <--------------- cokernel {-3} | a b c | : 0                             |
|c |    {-3} | 34 |                                                           |
|       {-4} | 0  |                                                           |
|                                                                             |
|0 0 0 0 | <------------------------ cokernel {-2} | a b c 0 0 0 0 0 0 | : 1  |
|c 0 0 0 |    {-2} | -18 -47 45  |            {-2} | 0 0 0 a b c 0 0 0 |      |
|0 a b c |    {-2} | -13 38  -34 |            {-2} | 0 0 0 0 0 0 a b c |      |
|             {-3} | 0   0   0   |                                            |
|                                                                             |
|cokernel {-1} | a b c 0 0 0 0 0 0 | : 2                                      |
|         {-1} | 0 0 0 a b c 0 0 0 |                                          |
|         {-1} | 0 0 0 0 0 0 a b c |                                          |
|                                                                             |
|| : 3                                                                        |
+-----------------------------------------------------------------------------+
|i16 : assert(gk == g ** id_(complex k))                                      |
+-----------------------------------------------------------------------------+

This routine is functorial.

+-----------------------------------------------------------------------------+
|i17 : D' = (freeResolution coker matrix{{a^2,a*b,c^3}})[-1]                  |
|                                                                             |
|       1      3      3      1                                                |
|o17 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      1      2      3      4                                                 |
|                                                                             |
|o17 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i18 : f' = randomComplexMap(D', D)                                           |
|                                                                             |
|           1              1                                                  |
|o18 = 1 : S  <---------- S  : 1                                              |
|                | 19 |                                                       |
|                                                                             |
|           3                                    3                            |
|      2 : S  <-------------------------------- S  : 2                        |
|                {2} | -16 15  39a+43b-17c  |                                 |
|                {2} | 7   -23 -11a+48b+36c |                                 |
|                {3} | 0   0   35           |                                 |
|                                                                             |
|           3                               2                                 |
|      3 : S  <--------------------------- S  : 3                             |
|                {3} | 11 -38a+33b+40c |                                      |
|                {5} | 0  0            |                                      |
|                {5} | 0  0            |                                      |
|                                                                             |
|o18 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i19 : (f' * f) ** g == (f' ** g) * (f ** id_E)                               |
|                                                                             |
|o19 = true                                                                   |
+-----------------------------------------------------------------------------+
|i20 : (f' * f) ** g == (f' ** id_F) * (f ** g)                               |
|                                                                             |
|o20 = true                                                                   |
+-----------------------------------------------------------------------------+
|i21 : F' = dual (freeResolution coker matrix{{a^2,a*b,a*c,b^3}})[-3]         |
|                                                                             |
|       1      4      4      1                                                |
|o21 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o21 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i22 : g' = randomComplexMap(F', F)                                           |
|                                                                             |
|           1                              2                                  |
|o22 = 0 : S  <-------------------------- S  : 0                              |
|                {-4} | 11a+46b-28c 1 |                                       |
|                                                                             |
|           4                                                                 |
|      1 : S  <---------------------------------------------------------------|
|                {-3} | -3a+22b-47c                    27a-22b+32c            |
|                {-3} | -23a-7b+2c                     -9a-32b-20c            |
|                {-3} | 29a-47b+15c                    24a-30b-48c            |
|                {-4} | -37a2-13ab+30b2-10ac-18bc+39c2 -15a2+39ab+33b2-49bc-33|
|                                                                             |
|           4                                                                 |
|      2 : S  <---------------------------------------------------------------|
|                {-2} | 9a2-39ab+13b2+4ac-26bc+22c2                          ||
|                {-2} | -49a2-11ab+43b2-8ac-8bc+36c2                         ||
|                {-2} | -3a2-22ab+41b2-30ac+16bc-28c2                        ||
|                {-3} | -6a3+35a2b-35ab2+3b3-9a2c+6abc-31b2c+40ac2+25bc2-2c3 ||
|                                                                             |
|o22 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                    3                                                        |
|------------------ S  : 1                                                    |
|   -19         |                                                             |
|   17          |                                                             |
|   -20         |                                                             |
|c2 44a-39b+36c |                                                             |
|                                                                             |
|    1                                                                        |
|-- S  : 2                                                                    |
+-----------------------------------------------------------------------------+
|i23 : f ** (g' * g) == (f ** g') * (id_C ** g)                               |
|                                                                             |
|o23 = true                                                                   |
+-----------------------------------------------------------------------------+
|i24 : f ** (g' * g) == (id_D ** g') * (f ** g)                               |
|                                                                             |
|o24 = true                                                                   |
+-----------------------------------------------------------------------------+

See also
========

  * Complex ** Complex -- tensor product of
    complexes
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes

Ways to use this method:
========================

  * "Complex ** ComplexMap"
  * "ComplexMap ** Complex"
  * ComplexMap ** ComplexMap -- the map of
    complexes between tensor complexes
  * "ComplexMap ** Module"
  * "Module ** ComplexMap"

ComplexMap ++ ComplexMap -- direct sum of complex maps
******************************************************

Synopsis
========

  * Operator: ++ (Macaulay2Doc),
  * Usage:
        h = f ++ g
        h = directSum(f,g,...)
        h = directSum(name1 => f, name2 => g, ...)
  * Inputs:
      * f, a map of complexes,
      * g, a map of complexes,
  * Outputs:
      * h, a map of complexes, that is the direct sum of the
        input chain  complex maps

Description
===========

The direct sum of two complex maps is a a complex map from the direct sum of
the sources to the direct sum of the targets.

First, we define some non-trivial maps of chain complexes.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a..d];                                                       |
+-----------------------------------------------------------------------------+
|i2 : C1 = (freeResolution coker matrix{{a,b,c}})[1]                          |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     -1     0      1      2                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : C2 = freeResolution coker matrix{{a*b,a*c,b*c}}                         |
|                                                                             |
|      1      3      2                                                        |
|o3 = R  <-- R  <-- R                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : D1 = (freeResolution coker matrix{{a,b,c}})                             |
|                                                                             |
|      1      3      3      1                                                 |
|o4 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o4 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i5 : D2 = freeResolution coker matrix{{a^2, b^2, c^2}}[-1]                   |
|                                                                             |
|      1      3      3      1                                                 |
|o5 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     1      2      3      4                                                  |
|                                                                             |
|o5 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i6 : f = randomComplexMap(D1, C1, Cycle => true)                             |
|                                                                             |
|                    1                                                        |
|o6 = -1 : 0 <----- R  : -1                                                   |
|               0                                                             |
|                                                                             |
|          1                                                        3         |
|     0 : R  <---------------------------------------------------- R  : 0     |
|               | -46a+17b-8c-24d 48a+6b+28c+29d 5a+3b-39c-29d |              |
|                                                                             |
|          3                                                                3 |
|     1 : R  <------------------------------------------------------------ R  |
|               {1} | -48a+3b-10c-29d -5a+36b+14c+29d 19b-34c          |      |
|               {1} | 46a+17b-29c-24d -39a+39c        -24a-3b-24c+29d  |      |
|               {1} | -18a+21b        -21a-22b-8c-24d -19a-32b+28c+29d |      |
|                                                                             |
|          3                               1                                  |
|     2 : R  <--------------------------- R  : 2                              |
|               {2} | 24a-36b-30c-29d |                                       |
|               {2} | 19a+19b-10c-29d |                                       |
|               {2} | -8a-22b-29c-24d |                                       |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|: 1                                                                          |
+-----------------------------------------------------------------------------+
|i7 : g = randomComplexMap(D2, C2, Cycle => true)                             |
|                                                                             |
|                   1                                                         |
|o7 = 0 : 0 <----- R  : 0                                                     |
|              0                                                              |
|                                                                             |
|          1                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               | 19a2+47ab-16b2-43ac-15bc-28c2-47cd 7a2+45ab-34b2+47ac-48bc-2|
|                                                                             |
|          3                                                2                 |
|     2 : R  <-------------------------------------------- R  : 2             |
|               {2} | -7b+19c          -38a+5b-16c-22d |                      |
|               {2} | -45a+34b+32c+47d 30a-34b-48c-47d |                      |
|               {2} | -43a+8b-28c-47d  -39a-23b        |                      |
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                                3                            |
|---------------------------------------------- R  : 1                        |
|3c2-47bd 38a2+2ab+15b2+16ac+47bc+39c2+22ad |                                 |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i8 : h = f ++ g                                                              |
|                                                                             |
|                    1                                                        |
|o8 = -1 : 0 <----- R  : -1                                                   |
|               0                                                             |
|                                                                             |
|          1                                                          4       |
|     0 : R  <------------------------------------------------------ R  : 0   |
|               | -46a+17b-8c-24d 48a+6b+28c+29d 5a+3b-39c-29d 0 |            |
|                                                                             |
|          4                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {1} | -48a+3b-10c-29d -5a+36b+14c+29d 19b-34c          0      |
|               {1} | 46a+17b-29c-24d -39a+39c        -24a-3b-24c+29d  0      |
|               {1} | -18a+21b        -21a-22b-8c-24d -19a-32b+28c+29d 0      |
|               {0} | 0               0               0                19a2+47|
|                                                                             |
|          6                                                                3 |
|     2 : R  <------------------------------------------------------------ R  |
|               {2} | 24a-36b-30c-29d 0                0               |      |
|               {2} | 19a+19b-10c-29d 0                0               |      |
|               {2} | -8a-22b-29c-24d 0                0               |      |
|               {2} | 0               -7b+19c          -38a+5b-16c-22d |      |
|               {2} | 0               -45a+34b+32c+47d 30a-34b-48c-47d |      |
|               {2} | 0               -43a+8b-28c-47d  -39a-23b        |      |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|                            0                                 0              |
|                            0                                 0              |
|                            0                                 0              |
|ab-16b2-43ac-15bc-28c2-47cd 7a2+45ab-34b2+47ac-48bc-23c2-47bd 38a2+2ab+15b2+1|
|                                                                             |
|                                                                             |
|: 2                                                                          |
|-----------------------------------------------------------------------------|
|                        6                                                    |
|---------------------- R  : 1                                                |
|                   |                                                         |
|                   |                                                         |
|                   |                                                         |
|6ac+47bc+39c2+22ad |                                                         |
+-----------------------------------------------------------------------------+
|i9 : assert isWellDefined h                                                  |
+-----------------------------------------------------------------------------+
|i10 : assert(h == map(D1 ++ D2, C1 ++ C2, {{f,0},{0,g}}))                    |
+-----------------------------------------------------------------------------+

The direct sum of any sequence of complex maps can be computed as follows.

+-----------------------------------------------------------------------------+
|i11 : directSum(f, g, f[2])                                                  |
|                                                                             |
|                     1                                                       |
|o11 = -3 : 0 <----- R  : -3                                                  |
|                0                                                            |
|                                                                             |
|            1                                                        3       |
|      -2 : R  <---------------------------------------------------- R  : -2  |
|                 | -46a+17b-8c-24d 48a+6b+28c+29d 5a+3b-39c-29d |            |
|                                                                             |
|            3                                                                |
|      -1 : R  <--------------------------------------------------------------|
|                 {1} | 0 -48a+3b-10c-29d -5a+36b+14c+29d 19b-34c          |  |
|                 {1} | 0 46a+17b-29c-24d -39a+39c        -24a-3b-24c+29d  |  |
|                 {1} | 0 -18a+21b        -21a-22b-8c-24d -19a-32b+28c+29d |  |
|                                                                             |
|           4                                                                 |
|      0 : R  <---------------------------------------------------------------|
|                {0} | -46a+17b-8c-24d 48a+6b+28c+29d 5a+3b-39c-29d 0 0       |
|                {2} | 0               0              0             0 24a-36b-|
|                {2} | 0               0              0             0 19a+19b-|
|                {2} | 0               0              0             0 -8a-22b-|
|                                                                             |
|           5                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {1} | -48a+3b-10c-29d -5a+36b+14c+29d 19b-34c          0     |
|                {1} | 46a+17b-29c-24d -39a+39c        -24a-3b-24c+29d  0     |
|                {1} | -18a+21b        -21a-22b-8c-24d -19a-32b+28c+29d 0     |
|                {0} | 0               0               0                19a2+4|
|                {3} | 0               0               0                0     |
|                                                                             |
|           6                                                                3|
|      2 : R  <------------------------------------------------------------ R |
|                {2} | 24a-36b-30c-29d 0                0               |     |
|                {2} | 19a+19b-10c-29d 0                0               |     |
|                {2} | -8a-22b-29c-24d 0                0               |     |
|                {2} | 0               -7b+19c          -38a+5b-16c-22d |     |
|                {2} | 0               -45a+34b+32c+47d 30a-34b-48c-47d |     |
|                {2} | 0               -43a+8b-28c-47d  -39a-23b        |     |
|                                                                             |
|o11 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|  4                                                                          |
| R  : -1                                                                     |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|             5                                                               |
|----------- R  : 0                                                           |
|        |                                                                    |
|30c-29d |                                                                    |
|10c-29d |                                                                    |
|29c-24d |                                                                    |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|                             0                                 0             |
|                             0                                 0             |
|                             0                                 0             |
|7ab-16b2-43ac-15bc-28c2-47cd 7a2+45ab-34b2+47ac-48bc-23c2-47bd 38a2+2ab+15b2+|
|                             0                                 0             |
|                                                                             |
|                                                                             |
| : 2                                                                         |
|-----------------------------------------------------------------------------|
|                         6                                                   |
|----------------------- R  : 1                                               |
|                    |                                                        |
|                    |                                                        |
|                    |                                                        |
|16ac+47bc+39c2+22ad |                                                        |
|                    |                                                        |
+-----------------------------------------------------------------------------+
|i12 : h2 = directSum(mike => f, greg => g, dan => f[2])                      |
|                                                                             |
|                     1                                                       |
|o12 = -3 : 0 <----- R  : -3                                                  |
|                0                                                            |
|                                                                             |
|            1                                                        3       |
|      -2 : R  <---------------------------------------------------- R  : -2  |
|                 | -46a+17b-8c-24d 48a+6b+28c+29d 5a+3b-39c-29d |            |
|                                                                             |
|            3                                                                |
|      -1 : R  <--------------------------------------------------------------|
|                 {1} | 0 -48a+3b-10c-29d -5a+36b+14c+29d 19b-34c          |  |
|                 {1} | 0 46a+17b-29c-24d -39a+39c        -24a-3b-24c+29d  |  |
|                 {1} | 0 -18a+21b        -21a-22b-8c-24d -19a-32b+28c+29d |  |
|                                                                             |
|           4                                                                 |
|      0 : R  <---------------------------------------------------------------|
|                {0} | -46a+17b-8c-24d 48a+6b+28c+29d 5a+3b-39c-29d 0 0       |
|                {2} | 0               0              0             0 24a-36b-|
|                {2} | 0               0              0             0 19a+19b-|
|                {2} | 0               0              0             0 -8a-22b-|
|                                                                             |
|           5                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {1} | -48a+3b-10c-29d -5a+36b+14c+29d 19b-34c          0     |
|                {1} | 46a+17b-29c-24d -39a+39c        -24a-3b-24c+29d  0     |
|                {1} | -18a+21b        -21a-22b-8c-24d -19a-32b+28c+29d 0     |
|                {0} | 0               0               0                19a2+4|
|                {3} | 0               0               0                0     |
|                                                                             |
|           6                                                                3|
|      2 : R  <------------------------------------------------------------ R |
|                {2} | 24a-36b-30c-29d 0                0               |     |
|                {2} | 19a+19b-10c-29d 0                0               |     |
|                {2} | -8a-22b-29c-24d 0                0               |     |
|                {2} | 0               -7b+19c          -38a+5b-16c-22d |     |
|                {2} | 0               -45a+34b+32c+47d 30a-34b-48c-47d |     |
|                {2} | 0               -43a+8b-28c-47d  -39a-23b        |     |
|                                                                             |
|o12 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|  4                                                                          |
| R  : -1                                                                     |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|             5                                                               |
|----------- R  : 0                                                           |
|        |                                                                    |
|30c-29d |                                                                    |
|10c-29d |                                                                    |
|29c-24d |                                                                    |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|                             0                                 0             |
|                             0                                 0             |
|                             0                                 0             |
|7ab-16b2-43ac-15bc-28c2-47cd 7a2+45ab-34b2+47ac-48bc-23c2-47bd 38a2+2ab+15b2+|
|                             0                                 0             |
|                                                                             |
|                                                                             |
| : 2                                                                         |
|-----------------------------------------------------------------------------|
|                         6                                                   |
|----------------------- R  : 1                                               |
|                    |                                                        |
|                    |                                                        |
|                    |                                                        |
|16ac+47bc+39c2+22ad |                                                        |
|                    |                                                        |
+-----------------------------------------------------------------------------+
|i13 : h2_[greg,dan]                                                          |
|                                                                             |
|            1                                                        3       |
|o13 = -2 : R  <---------------------------------------------------- R  : -2  |
|                 | -46a+17b-8c-24d 48a+6b+28c+29d 5a+3b-39c-29d |            |
|                                                                             |
|            3                                                                |
|      -1 : R  <------------------------------------------------------------ R|
|                 {1} | -48a+3b-10c-29d -5a+36b+14c+29d 19b-34c          |    |
|                 {1} | 46a+17b-29c-24d -39a+39c        -24a-3b-24c+29d  |    |
|                 {1} | -18a+21b        -21a-22b-8c-24d -19a-32b+28c+29d |    |
|                                                                             |
|           4                                 2                               |
|      0 : R  <----------------------------- R  : 0                           |
|                {0} | 0 0               |                                    |
|                {2} | 0 24a-36b-30c-29d |                                    |
|                {2} | 0 19a+19b-10c-29d |                                    |
|                {2} | 0 -8a-22b-29c-24d |                                    |
|                                                                             |
|           5                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {1} | 0                                  0                   |
|                {1} | 0                                  0                   |
|                {1} | 0                                  0                   |
|                {0} | 19a2+47ab-16b2-43ac-15bc-28c2-47cd 7a2+45ab-34b2+47ac-4|
|                {3} | 0                                  0                   |
|                                                                             |
|           6                                                2                |
|      2 : R  <-------------------------------------------- R  : 2            |
|                {2} | 0                0               |                     |
|                {2} | 0                0               |                     |
|                {2} | 0                0               |                     |
|                {2} | -7b+19c          -38a+5b-16c-22d |                     |
|                {2} | -45a+34b+32c+47d 30a-34b-48c-47d |                     |
|                {2} | -43a+8b-28c-47d  -39a-23b        |                     |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|3                                                                            |
|  : -1                                                                       |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                     3                       |
|--------------------------------------------------- R  : 1                   |
|              0                                 |                            |
|              0                                 |                            |
|              0                                 |                            |
|8bc-23c2-47bd 38a2+2ab+15b2+16ac+47bc+39c2+22ad |                            |
|              0                                 |                            |
+-----------------------------------------------------------------------------+
|i14 : assert(source oo == C2 ++ C1[2])                                       |
+-----------------------------------------------------------------------------+

One can easily obtain the compositions with canonical injections and
surjections.

+--------------------+
|i15 : h_[0]^[0] == f|
|                    |
|o15 = true          |
+--------------------+
|i16 : h_[1]^[1] == g|
|                    |
|o16 = true          |
+--------------------+
|i17 : h_[0]^[1] == 0|
|                    |
|o17 = true          |
+--------------------+
|i18 : h_[1]^[0] == 0|
|                    |
|o18 = true          |
+--------------------+
+---------------------------------+
|i19 : h_[0] == h * (C1 ++ C2)_[0]|
|                                 |
|o19 = true                       |
+---------------------------------+
|i20 : h_[1] == h * (C1 ++ C2)_[1]|
|                                 |
|o20 = true                       |
+---------------------------------+
|i21 : h^[0] == (D1 ++ D2)^[0] * h|
|                                 |
|o21 = true                       |
+---------------------------------+
|i22 : h^[1] == (D1 ++ D2)^[1] * h|
|                                 |
|o22 = true                       |
+---------------------------------+

See also
========

  * Complex ++ Complex -- direct sum of
    complexes
  * ComplexMap ** ComplexMap -- the map of
    complexes between tensor complexes
  * Hom(ComplexMap,ComplexMap) -- the
    map of complexes between Hom complexes
  * ComplexMap _ Array -- the composition with the
    canonical inclusion or projection map

Ways to use this method:
========================

  * ComplexMap ++ ComplexMap -- direct sum of
    complex maps

ComplexMap == ComplexMap -- whether two complex maps are equal
**************************************************************

Synopsis
========

  * Operator: == (Macaulay2Doc),
  * Usage:
        f == g
        f == 0
        f == 1
  * Inputs:
      * f, a map of complexes, or 0, or 1.
      * g, a map of complexes, or 0, or 1.
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when f and
        g are equal

Description
===========

Two complex maps are equal if they have the same source, the same target, and
$f_i = g_i$ for all $i$.

+-------------------------------------+
|i1 : S = ZZ/101[a..c]                |
|                                     |
|o1 = S                               |
|                                     |
|o1 : PolynomialRing                  |
+-------------------------------------+
|i2 : C = freeResolution coker vars S |
|                                     |
|      1      3      3      1         |
|o2 = S  <-- S  <-- S  <-- S          |
|                                     |
|     0      1      2      3          |
|                                     |
|o2 : Complex                         |
+-------------------------------------+
|i3 : f = id_C                        |
|                                     |
|          1             1            |
|o3 = 0 : S  <--------- S  : 0        |
|               | 1 |                 |
|                                     |
|          3                     3    |
|     1 : S  <----------------- S  : 1|
|               {1} | 1 0 0 |         |
|               {1} | 0 1 0 |         |
|               {1} | 0 0 1 |         |
|                                     |
|          3                     3    |
|     2 : S  <----------------- S  : 2|
|               {2} | 1 0 0 |         |
|               {2} | 0 1 0 |         |
|               {2} | 0 0 1 |         |
|                                     |
|          1                 1        |
|     3 : S  <------------- S  : 3    |
|               {3} | 1 |             |
|                                     |
|o3 : ComplexMap                      |
+-------------------------------------+
|i4 : assert(f == 1)                  |
+-------------------------------------+
|i5 : f === id_C[-1][1]               |
|                                     |
|o5 = false                           |
+-------------------------------------+
|i6 : f == id_C[-1][1]                |
|                                     |
|o6 = true                            |
+-------------------------------------+

A complex map is equal to zero if all the maps are zero. This could require
computation to determine if something that is superficially not zero is in fact
zero.

+--------------------------+
|i7 : assert(0 * id_C == 0)|
+--------------------------+
+---------------------------------------------------+
|i8 : g = randomComplexMap(C, C)                    |
|                                                   |
|          1              1                         |
|o8 = 0 : S  <---------- S  : 0                     |
|               | 24 |                              |
|                                                   |
|          3                           3            |
|     1 : S  <----------------------- S  : 1        |
|               {1} | -36 19  -29 |                 |
|               {1} | -30 19  -8  |                 |
|               {1} | -29 -10 -22 |                 |
|                                                   |
|          3                           3            |
|     2 : S  <----------------------- S  : 2        |
|               {2} | -29 -16 34  |                 |
|               {2} | -24 39  19  |                 |
|               {2} | -38 21  -47 |                 |
|                                                   |
|          1                   1                    |
|     3 : S  <--------------- S  : 3                |
|               {3} | -39 |                         |
|                                                   |
|o8 : ComplexMap                                    |
+---------------------------------------------------+
|i9 : h = canonicalMap(coker g, target g)           |
|                                                   |
|                                 1                 |
|o9 = 0 : cokernel | 24 | <----- S  : 0             |
|                            0                      |
|                                                   |
|                                              3    |
|     1 : cokernel {1} | -36 19  -29 | <----- S  : 1|
|                  {1} | -30 19  -8  |    0         |
|                  {1} | -29 -10 -22 |              |
|                                                   |
|                                              3    |
|     2 : cokernel {2} | -29 -16 34  | <----- S  : 2|
|                  {2} | -24 39  19  |    0         |
|                  {2} | -38 21  -47 |              |
|                                                   |
|                                      1            |
|     3 : cokernel {3} | -39 | <----- S  : 3        |
|                                 0                 |
|                                                   |
|o9 : ComplexMap                                    |
+---------------------------------------------------+
|i10 : assert(h == 0)                               |
+---------------------------------------------------+

Testing whether a map is equal to 1 is a shorthand for determining if the
complex map is the identity. Although the matrices may appear to be the
identity, the map is not the identity when the source and target are not equal.

+-----------------------------------------------------------------------------+
|i11 : g = randomComplexMap(C, C, InternalDegree=>1, Cycle=>true)             |
|                                                                             |
|           1                       1                                         |
|o11 = 0 : S  <------------------- S  : 0                                     |
|                | -33a-3b+13c |                                              |
|                                                                             |
|           3                                                 3               |
|      1 : S  <--------------------------------------------- S  : 1           |
|                {1} | -33a+25b-41c -37b+34c -45b+33c    |                    |
|                {1} | -28a+16c     4a-3b+4c 45a-37c     |                    |
|                {1} | -47a-16b     -34a+9b  35a+34b+13c |                    |
|                                                                             |
|           3                                                  3              |
|      2 : S  <---------------------------------------------- S  : 2          |
|                {2} | 4a+25b-43c 45a+38c     45b-22c     |                   |
|                {2} | -34a+2b    35a-13b-41c -48b+34c    |                   |
|                {2} | -47a+16b   47a+16c     -18a+34b+4c |                   |
|                                                                             |
|           1                            1                                    |
|      3 : S  <------------------------ S  : 3                                |
|                {3} | -18a-13b-43c |                                         |
|                                                                             |
|o11 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i12 : h = canonicalMap(coker g, target g)                                    |
|                                                                             |
|                                               1                             |
|o12 = 0 : cokernel | -33a-3b+13c | <--------- S  : 0                         |
|                                      | 1 |                                  |
|                                                                             |
|                                                                             |
|      1 : cokernel {1} | -33a+25b-41c -37b+34c -45b+33c    |                 |
|                   {1} | -28a+16c     4a-3b+4c 45a-37c     |                 |
|                   {1} | -47a-16b     -34a+9b  35a+34b+13c |                 |
|                                                                             |
|                                                                             |
|                                                                             |
|      2 : cokernel {2} | 4a+25b-43c 45a+38c     45b-22c     |                |
|                   {2} | -34a+2b    35a-13b-41c -48b+34c    |                |
|                   {2} | -47a+16b   47a+16c     -18a+34b+4c |                |
|                                                                             |
|                                                                             |
|                                                        1                    |
|      3 : cokernel {3} | -18a-13b-43c | <------------- S  : 3                |
|                                           {3} | 1 |                         |
|                                                                             |
|o12 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                    3                                                        |
|<----------------- S  : 1                                                    |
|   {1} | 1 0 0 |                                                             |
|   {1} | 0 1 0 |                                                             |
|   {1} | 0 0 1 |                                                             |
|                                                                             |
|                     3                                                       |
| <----------------- S  : 2                                                   |
|    {2} | 1 0 0 |                                                            |
|    {2} | 0 1 0 |                                                            |
|    {2} | 0 0 1 |                                                            |
+-----------------------------------------------------------------------------+
|i13 : assert(h != 1)                                                         |
+-----------------------------------------------------------------------------+

Testing for equality is not the same testing for isomorphism. In particular,
different presentations of a complex need not be equal.

+-----------------------------------------------------------------------------+
|i14 : D = prune image g                                                      |
|                                                                             |
|       1      3      3      1                                                |
|o14 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o14 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i15 : p = D.cache.pruningMap                                                 |
|                                                                             |
|                                                1                            |
|o15 = 0 : image | -33a-3b+13c | <------------- S  : 0                        |
|                                   {1} | 1 |                                 |
|                                                                             |
|                                                                             |
|      1 : image {1} | -33a+25b-41c -37b+34c -45b+33c    | <----------------- |
|                {1} | -28a+16c     4a-3b+4c 45a-37c     |    {2} | 1 0 0 |   |
|                {1} | -47a-16b     -34a+9b  35a+34b+13c |    {2} | 0 1 0 |   |
|                                                             {2} | 0 0 1 |   |
|                                                                             |
|                                                                             |
|      2 : image {2} | 4a+25b-43c 45a+38c     45b-22c     | <-----------------|
|                {2} | -34a+2b    35a-13b-41c -48b+34c    |    {3} | 1 0 0 |  |
|                {2} | -47a+16b   47a+16c     -18a+34b+4c |    {3} | 0 1 0 |  |
|                                                              {3} | 0 0 1 |  |
|                                                                             |
|                                                     1                       |
|      3 : image {3} | -18a-13b-43c | <------------- S  : 3                   |
|                                        {4} | 1 |                            |
|                                                                             |
|o15 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
| 3                                                                           |
|S  : 1                                                                       |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|  3                                                                          |
| S  : 2                                                                      |
+-----------------------------------------------------------------------------+
|i16 : p == 1                                                                 |
|                                                                             |
|o16 = false                                                                  |
+-----------------------------------------------------------------------------+
|i17 : assert(coker p == 0 and ker p == 0)                                    |
+-----------------------------------------------------------------------------+
|i18 : assert(prune p == 1)                                                   |
+-----------------------------------------------------------------------------+

See also
========

  * Complex == Complex -- whether two complexes are
    equal
  * ComplexMap Array -- shift a complex or complex map
  * randomComplexMap -- a
    random map of chain complexes
  * canonicalMap -- gets the natural map arising from
    various constructions
  * prune(Complex) -- minimal
    presentation of all terms in a complex

Ways to use this method:
========================

  * ComplexMap == ComplexMap -- whether two
    complex maps are equal
  * "ComplexMap == ZZ"
  * "ZZ == ComplexMap"

ComplexMap ^ Array -- the composition with the canonical inclusion or projection map
************************************************************************************

Synopsis
========

  * Operator: ^ (Macaulay2Doc),
  * Usage:
        i = f_[name]
        p = f^[name]
  * Inputs:
      * f, a map of complexes,
      * name, an array (Macaulay2Doc),
  * Outputs:
      * a map of complexes, i is the composition of f with
        the canonical inclusion and p is the composition of the canonical
        projection with f

Description
===========

The direct sum is an n-ary operator with projection and inclusion maps from
each component satisfying appropriate identities.

One can access these maps as follows.  First, we define some non-trivial maps
of chain complexes.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a..d];                                                       |
+-----------------------------------------------------------------------------+
|i2 : C1 = (freeResolution coker matrix{{a,b,c}})[1]                          |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     -1     0      1      2                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : C2 = freeResolution coker matrix{{a*b,a*c,b*c}}                         |
|                                                                             |
|      1      3      2                                                        |
|o3 = R  <-- R  <-- R                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : D1 = (freeResolution coker matrix{{a,b,c}})                             |
|                                                                             |
|      1      3      3      1                                                 |
|o4 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o4 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i5 : D2 = freeResolution coker matrix{{a^2, b^2, c^2}}[-1]                   |
|                                                                             |
|      1      3      3      1                                                 |
|o5 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     1      2      3      4                                                  |
|                                                                             |
|o5 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i6 : f = randomComplexMap(D1, C1, Cycle => true)                             |
|                                                                             |
|                    1                                                        |
|o6 = -1 : 0 <----- R  : -1                                                   |
|               0                                                             |
|                                                                             |
|          1                                                        3         |
|     0 : R  <---------------------------------------------------- R  : 0     |
|               | -46a+17b-8c-24d 48a+6b+28c+29d 5a+3b-39c-29d |              |
|                                                                             |
|          3                                                                3 |
|     1 : R  <------------------------------------------------------------ R  |
|               {1} | -48a+3b-10c-29d -5a+36b+14c+29d 19b-34c          |      |
|               {1} | 46a+17b-29c-24d -39a+39c        -24a-3b-24c+29d  |      |
|               {1} | -18a+21b        -21a-22b-8c-24d -19a-32b+28c+29d |      |
|                                                                             |
|          3                               1                                  |
|     2 : R  <--------------------------- R  : 2                              |
|               {2} | 24a-36b-30c-29d |                                       |
|               {2} | 19a+19b-10c-29d |                                       |
|               {2} | -8a-22b-29c-24d |                                       |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|: 1                                                                          |
+-----------------------------------------------------------------------------+
|i7 : g = randomComplexMap(D2, C2, Cycle => true)                             |
|                                                                             |
|                   1                                                         |
|o7 = 0 : 0 <----- R  : 0                                                     |
|              0                                                              |
|                                                                             |
|          1                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               | 19a2+47ab-16b2-43ac-15bc-28c2-47cd 7a2+45ab-34b2+47ac-48bc-2|
|                                                                             |
|          3                                                2                 |
|     2 : R  <-------------------------------------------- R  : 2             |
|               {2} | -7b+19c          -38a+5b-16c-22d |                      |
|               {2} | -45a+34b+32c+47d 30a-34b-48c-47d |                      |
|               {2} | -43a+8b-28c-47d  -39a-23b        |                      |
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                                3                            |
|---------------------------------------------- R  : 1                        |
|3c2-47bd 38a2+2ab+15b2+16ac+47bc+39c2+22ad |                                 |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i8 : h = f ++ g                                                              |
|                                                                             |
|                    1                                                        |
|o8 = -1 : 0 <----- R  : -1                                                   |
|               0                                                             |
|                                                                             |
|          1                                                          4       |
|     0 : R  <------------------------------------------------------ R  : 0   |
|               | -46a+17b-8c-24d 48a+6b+28c+29d 5a+3b-39c-29d 0 |            |
|                                                                             |
|          4                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {1} | -48a+3b-10c-29d -5a+36b+14c+29d 19b-34c          0      |
|               {1} | 46a+17b-29c-24d -39a+39c        -24a-3b-24c+29d  0      |
|               {1} | -18a+21b        -21a-22b-8c-24d -19a-32b+28c+29d 0      |
|               {0} | 0               0               0                19a2+47|
|                                                                             |
|          6                                                                3 |
|     2 : R  <------------------------------------------------------------ R  |
|               {2} | 24a-36b-30c-29d 0                0               |      |
|               {2} | 19a+19b-10c-29d 0                0               |      |
|               {2} | -8a-22b-29c-24d 0                0               |      |
|               {2} | 0               -7b+19c          -38a+5b-16c-22d |      |
|               {2} | 0               -45a+34b+32c+47d 30a-34b-48c-47d |      |
|               {2} | 0               -43a+8b-28c-47d  -39a-23b        |      |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|                            0                                 0              |
|                            0                                 0              |
|                            0                                 0              |
|ab-16b2-43ac-15bc-28c2-47cd 7a2+45ab-34b2+47ac-48bc-23c2-47bd 38a2+2ab+15b2+1|
|                                                                             |
|                                                                             |
|: 2                                                                          |
|-----------------------------------------------------------------------------|
|                        6                                                    |
|---------------------- R  : 1                                                |
|                   |                                                         |
|                   |                                                         |
|                   |                                                         |
|6ac+47bc+39c2+22ad |                                                         |
+-----------------------------------------------------------------------------+

The four basic maps are the inclusion from each summand of the source and the
projection to each summand of the target.

+---------------------------------+
|i9 : h_[0] == h * (C1 ++ C2)_[0] |
|                                 |
|o9 = true                        |
+---------------------------------+
|i10 : h_[1] == h * (C1 ++ C2)_[1]|
|                                 |
|o10 = true                       |
+---------------------------------+
|i11 : h^[0] == (D1 ++ D2)^[0] * h|
|                                 |
|o11 = true                       |
+---------------------------------+
|i12 : h^[1] == (D1 ++ D2)^[1] * h|
|                                 |
|o12 = true                       |
+---------------------------------+

These can be combined to obtain the blocks of the map of chain complexes.

+---------------------------------------------------------+
|i13 : h_[0]^[0] == f                                     |
|                                                         |
|o13 = true                                               |
+---------------------------------------------------------+
|i14 : h_[1]^[1] == g                                     |
|                                                         |
|o14 = true                                               |
+---------------------------------------------------------+
|i15 : h_[0]^[1] == 0                                     |
|                                                         |
|o15 = true                                               |
+---------------------------------------------------------+
|i16 : h_[1]^[0] == 0                                     |
|                                                         |
|o16 = true                                               |
+---------------------------------------------------------+
|i17 : assert(h == map(D1 ++ D2, C1 ++ C2, {{f,0},{0,g}}))|
+---------------------------------------------------------+

The default names for the components are the non-negative integers.  However,
one can choose any name.

+-----------------------------------------------------------------------------+
|i18 : h = (mike => f) ++ (greg => g)                                         |
|                                                                             |
|                     1                                                       |
|o18 = -1 : 0 <----- R  : -1                                                  |
|                0                                                            |
|                                                                             |
|           1                                                          4      |
|      0 : R  <------------------------------------------------------ R  : 0  |
|                | -46a+17b-8c-24d 48a+6b+28c+29d 5a+3b-39c-29d 0 |           |
|                                                                             |
|           4                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {1} | -48a+3b-10c-29d -5a+36b+14c+29d 19b-34c          0     |
|                {1} | 46a+17b-29c-24d -39a+39c        -24a-3b-24c+29d  0     |
|                {1} | -18a+21b        -21a-22b-8c-24d -19a-32b+28c+29d 0     |
|                {0} | 0               0               0                19a2+4|
|                                                                             |
|           6                                                                3|
|      2 : R  <------------------------------------------------------------ R |
|                {2} | 24a-36b-30c-29d 0                0               |     |
|                {2} | 19a+19b-10c-29d 0                0               |     |
|                {2} | -8a-22b-29c-24d 0                0               |     |
|                {2} | 0               -7b+19c          -38a+5b-16c-22d |     |
|                {2} | 0               -45a+34b+32c+47d 30a-34b-48c-47d |     |
|                {2} | 0               -43a+8b-28c-47d  -39a-23b        |     |
|                                                                             |
|o18 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|                             0                                 0             |
|                             0                                 0             |
|                             0                                 0             |
|7ab-16b2-43ac-15bc-28c2-47cd 7a2+45ab-34b2+47ac-48bc-23c2-47bd 38a2+2ab+15b2+|
|                                                                             |
|                                                                             |
| : 2                                                                         |
|-----------------------------------------------------------------------------|
|                         6                                                   |
|----------------------- R  : 1                                               |
|                    |                                                        |
|                    |                                                        |
|                    |                                                        |
|16ac+47bc+39c2+22ad |                                                        |
+-----------------------------------------------------------------------------+
|i19 : h_[mike]^[mike] == f                                                   |
|                                                                             |
|o19 = true                                                                   |
+-----------------------------------------------------------------------------+
|i20 : h_[greg]^[greg] == g                                                   |
|                                                                             |
|o20 = true                                                                   |
+-----------------------------------------------------------------------------+

See also
========

  * Complex ++ Complex -- direct sum of
    complexes
  * Complex ^ Array -- the canonical inclusion or
    projection map of a direct sum
  * Complex _ Array -- the canonical inclusion or
    projection map of a direct sum
  * directSum(Complex) -- direct sum of
    complexes
  * components(Complex) -- list the components
    of a direct sum
  * indices (Macaulay2Doc) -- indices of a polynomial; also
    components for a direct sum

Ways to use this method:
========================

  * ComplexMap ^ Array -- the composition with the
    canonical inclusion or projection map

ComplexMap ^ ZZ -- the n-fold composition
*****************************************

Synopsis
========

  * Operator: ^ (Macaulay2Doc),
  * Usage:
        f^n
  * Inputs:
      * f, a map of complexes, whose source and target are
        the same complex
      * n, an integer (Macaulay2Doc),
  * Outputs:
      * a map of complexes, the composition of $f$ with
        itself $n$ times.

Description
===========

A complex map $f : C \to C$ can be composed with itself. This method produces
these new maps of chain complexes.

The differential on a chain complex always composes with itself to give the
zero map.

+-----------------------------------------------------+
|i1 : S = ZZ/101[a..c];                               |
+-----------------------------------------------------+
|i2 : C = freeResolution coker matrix{{a^2, b^2, c^2}}|
|                                                     |
|      1      3      3      1                         |
|o2 = S  <-- S  <-- S  <-- S                          |
|                                                     |
|     0      1      2      3                          |
|                                                     |
|o2 : Complex                                         |
+-----------------------------------------------------+
|i3 : f = dd^C                                        |
|                                                     |
|          1                    3                     |
|o3 = 0 : S  <---------------- S  : 1                 |
|               | a2 b2 c2 |                          |
|                                                     |
|          3                           3              |
|     1 : S  <----------------------- S  : 2          |
|               {2} | -b2 -c2 0   |                   |
|               {2} | a2  0   -c2 |                   |
|               {2} | 0   a2  b2  |                   |
|                                                     |
|          3                   1                      |
|     2 : S  <--------------- S  : 3                  |
|               {4} | c2  |                           |
|               {4} | -b2 |                           |
|               {4} | a2  |                           |
|                                                     |
|o3 : ComplexMap                                      |
+-----------------------------------------------------+
|i4 : f^2                                             |
|                                                     |
|o4 = 0                                               |
|                                                     |
|o4 : ComplexMap                                      |
+-----------------------------------------------------+
|i5 : assert(source f == target f)                    |
+-----------------------------------------------------+
|i6 : assert(degree f == -1)                          |
+-----------------------------------------------------+
|i7 : assert(degree f^2 == -2)                        |
+-----------------------------------------------------+
+-----------------------------------------------------------------------------+
|i8 : g = randomComplexMap(C, C, Degree => -1)                                |
|                                                                             |
|                    1                                                        |
|o8 = -1 : 0 <----- S  : 0                                                    |
|               0                                                             |
|                                                                             |
|          1                                                                  |
|     0 : S  <----------------------------------------------------------------|
|               | 24a2-36ab-29b2-30ac+19bc+19c2 -10a2-29ab-22b2-8ac-29bc-24c2 |
|                                                                             |
|          3                                                                  |
|     1 : S  <----------------------------------------------------------------|
|               {2} | -47a2-39ab-13b2-18ac-43bc-15c2 -16a2+7ab-23b2+15ac+39bc+|
|               {2} | -28a2-47ab+2b2+38ac+16bc+22c2  -17a2-11ab+36b2+48ac+35bc|
|               {2} | 45a2-34ab-47b2-48ac+47bc+19c2  -38a2+33ab+11b2+40ac+46bc|
|                                                                             |
|          3                                              1                   |
|     2 : S  <------------------------------------------ S  : 3               |
|               {4} | 32a2-9ab-20b2-32ac+24bc-30c2   |                        |
|               {4} | -48a2-15ab+39ac+33bc-49c2      |                        |
|               {4} | -33a2-19ab-20b2+17ac+44bc-39c2 |                        |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                    3                                        |
|---------------------------------- S  : 1                                    |
|-38a2-16ab+21b2+39ac+34bc+19c2 |                                             |
|                                                                             |
|                                          3                                  |
|---------------------------------------- S  : 2                              |
|43c2  a2-3ab-47b2+22ac-23bc-7c2      |                                       |
|+11c2 2a2+29ab+15b2-47ac-37bc-13c2   |                                       |
|-28c2 -10a2+30ab+39b2-18ac+27bc-22c2 |                                       |
+-----------------------------------------------------------------------------+
|i9 : g^2                                                                     |
|                                                                             |
|          1                                                                  |
|o9 = 0 : S  <----------------------------------------------------------------|
|               | -33a4-16a3b+13a2b2-13ab3-48b4-43a3c+15a2bc+47ab2c-21b3c+19a2|
|                                                                             |
|          3                                                                  |
|     1 : S  <----------------------------------------------------------------|
|               {2} | 39a4-33a3b+28a2b2-27ab3-12b4-14a3c+19a2bc-39ab2c-b3c-37a|
|               {2} | -45a4-50a3b+14a2b2+22ab3-37b4+23a3c+4a2bc-22ab2c-7b3c+37|
|               {2} | -42a4+26a3b-31a2b2+ab3-42b4+5a3c+42a2bc+45ab2c-24b3c+7a2|
|                                                                             |
|o9 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|c2-35abc2-16b2c2-40ac3+21bc3-48c4 18a4-6a3b-34a2b2+37ab3+5b4+19a3c-36a2bc+13a|
|                                                                             |
|                                         1                                   |
|--------------------------------------- S  : 3                               |
|2c2-37abc2+3b2c2-25ac3+17bc3+30c4   |                                        |
|a2c2+41abc2+49b2c2-34ac3-29bc3+15c4 |                                        |
|c2+35abc2+12b2c2+27ac3+8bc3+44c4    |                                        |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|b2c-22b3c-27a2c2+40b2c2+49ac3+18bc3+21c4 -20a4-22a3b-14a2b2+5ab3+34b4+34a3c-3|
|-----------------------------------------------------------------------------|
|                                                            3                |
|---------------------------------------------------------- S  : 2            |
|a2bc-24ab2c+26b3c-3a2c2-34abc2-42b2c2-47ac3-45bc3-37c4 |                     |
+-----------------------------------------------------------------------------+
|i10 : g^3                                                                    |
|                                                                             |
|           1                                                                 |
|o10 = 0 : S  <---------------------------------------------------------------|
|                | -48a6-20a4b2-29a3b3+23a2b4-28ab5-23b6+28a5c-17a4bc-4a3b2c+4|
|                                                                             |
|o10 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|6a2b3c-27ab4c+5b5c+31a4c2-30a3bc2-39a2b2c2-48ab3c2+34b4c2-13a3c3-15a2bc3+47ab|
|-----------------------------------------------------------------------------|
|                                                      1                      |
|---------------------------------------------------- S  : 3                  |
|2c3-41b3c3+20a2c4+40abc4-34b2c4+35ac5-26bc5+36c6 |                           |
+-----------------------------------------------------------------------------+
|i11 : assert(g^4 == 0)                                                       |
+-----------------------------------------------------------------------------+

The zero-th power returns the identity map

+-----------------+
|i12 : f^0 == id_C|
|                 |
|o12 = true       |
+-----------------+
|i13 : g^0 == id_C|
|                 |
|o13 = true       |
+-----------------+

When $n$ is negative, the result is the $n$-fold power of the inverse complex
map, if it exists.

+--------------------------------------------+
|i14 : h = randomComplexMap(C, C)            |
|                                            |
|           1              1                 |
|o14 = 0 : S  <---------- S  : 0             |
|                | 36 |                      |
|                                            |
|           3                           3    |
|      1 : S  <----------------------- S  : 1|
|                {2} | 9   13  -49 |         |
|                {2} | -39 -26 -11 |         |
|                {2} | 4   22  -8  |         |
|                                            |
|           3                          3     |
|      2 : S  <---------------------- S  : 2 |
|                {4} | 43 -3  41  |          |
|                {4} | -8 -22 16  |          |
|                {4} | 36 -30 -28 |          |
|                                            |
|           1                  1             |
|      3 : S  <-------------- S  : 3         |
|                {6} | -6 |                  |
|                                            |
|o14 : ComplexMap                            |
+--------------------------------------------+
|i15 : h^-1                                  |
|                                            |
|           1               1                |
|o15 = 0 : S  <----------- S  : 0            |
|                | -14 |                     |
|                                            |
|           3                          3     |
|      1 : S  <---------------------- S  : 1 |
|                {2} | 31 -46 -13 |          |
|                {2} | 6  -35 24  |          |
|                {2} | 32 7   -29 |          |
|                                            |
|           3                           3    |
|      2 : S  <----------------------- S  : 2|
|                {4} | 32  -45 50  |         |
|                {4} | -17 -6  33  |         |
|                {4} | -20 -37 -18 |         |
|                                            |
|           1                   1            |
|      3 : S  <--------------- S  : 3        |
|                {6} | -17 |                 |
|                                            |
|o15 : ComplexMap                            |
+--------------------------------------------+
|i16 : assert(h * h^-1 == id_C)              |
+--------------------------------------------+
|i17 : h^-4                                  |
|                                            |
|           1              1                 |
|o17 = 0 : S  <---------- S  : 0             |
|                | 36 |                      |
|                                            |
|           3                           3    |
|      1 : S  <----------------------- S  : 1|
|                {2} | -43 41  -32 |         |
|                {2} | -16 41  -10 |         |
|                {2} | 31  -33 -29 |         |
|                                            |
|           3                           3    |
|      2 : S  <----------------------- S  : 2|
|                {4} | -6  -30 11  |         |
|                {4} | 4   15  -50 |         |
|                {4} | -31 -23 -1  |         |
|                                            |
|           1                  1             |
|      3 : S  <-------------- S  : 3         |
|                {6} | -6 |                  |
|                                            |
|o17 : ComplexMap                            |
+--------------------------------------------+
|i18 : assert(h^-4 * h^4 == id_C)            |
+--------------------------------------------+

See also
========

  * Matrix ^ ZZ (Macaulay2Doc) -- power
  * Complex ^ ZZ -- access individual object in a
    complex

Ways to use this method:
========================

  * ComplexMap ^ ZZ -- the n-fold composition

ComplexMap _ ZZ -- access individual matrices in a complex map
**************************************************************

Synopsis
========

  * Operator: _ (Macaulay2Doc),
  * Usage:
        f_i
  * Inputs:
      * f, a map of complexes,
      * i, an integer (Macaulay2Doc), the homological index
  * Outputs:
      * a matrix (Macaulay2Doc), the i-th map

Description
===========

A complex map $f : C \to D$ of degree $d$ is a sequence of maps $f_i : C_i \to
D_{i+d}$. This method allows one to access the individual $f_i$.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..c];                                                       |
+-----------------------------------------------------------------------------+
|i2 : C = freeResolution coker matrix{{a^2, b^2, c^2}}                        |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : D = freeResolution coker vars S                                         |
|                                                                             |
|      1      3      3      1                                                 |
|o3 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : f = randomComplexMap(D, C)                                              |
|                                                                             |
|          1              1                                                   |
|o4 = 0 : S  <---------- S  : 0                                               |
|               | 24 |                                                        |
|                                                                             |
|          3                                                      3           |
|     1 : S  <-------------------------------------------------- S  : 1       |
|               {1} | -36a-30b-29c -29a-24b-38c -39a-18b-13c |                |
|               {1} | 19a+19b-10c  -16a+39b+21c -43a-15b-28c |                |
|               {1} | -29a-8b-22c  34a+19b-47c  -47a+38b+2c  |                |
|                                                                             |
|          3                                                                  |
|     2 : S  <----------------------------------------------------------------|
|               {2} | 16a2+22ab-34b2+45ac-48bc-47c2 35a2+11ab+33b2-38ac+40bc+1|
|               {2} | 47a2+19ab+7b2-16ac+15bc-23c2  46a2-28ab-3b2+ac+22bc-47c2|
|               {2} | 39a2+43ab-11b2-17ac+48bc+36c2 -23a2-7ab+29b2+2ac-47bc+15|
|                                                                             |
|          1                                                                  |
|     3 : S  <----------------------------------------------------------------|
|               {3} | 33a3-49a2b-19ab2+44b3-33a2c+17abc-39b2c-20ac2+36bc2+9c3 |
|                                                                             |
|o4 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                        3                                    |
|-------------------------------------- S  : 2                                |
|1c2 -37a2-13ab+30b2-10ac-18bc+39c2 |                                         |
|    27a2-22ab-9b2+32ac-32bc-20c2   |                                         |
|c2  24a2-30ab-15b2-48ac+39bc       |                                         |
|                                                                             |
|     1                                                                       |
|--- S  : 3                                                                   |
||                                                                            |
+-----------------------------------------------------------------------------+
|i5 : f_2                                                                     |
|                                                                             |
|o5 = {2} | 16a2+22ab-34b2+45ac-48bc-47c2 35a2+11ab+33b2-38ac+40bc+11c2       |
|     {2} | 47a2+19ab+7b2-16ac+15bc-23c2  46a2-28ab-3b2+ac+22bc-47c2          |
|     {2} | 39a2+43ab-11b2-17ac+48bc+36c2 -23a2-7ab+29b2+2ac-47bc+15c2        |
|     ------------------------------------------------------------------------|
|     -37a2-13ab+30b2-10ac-18bc+39c2 |                                        |
|     27a2-22ab-9b2+32ac-32bc-20c2   |                                        |
|     24a2-30ab-15b2-48ac+39bc       |                                        |
|                                                                             |
|             3       3                                                       |
|o5 : Matrix S  <--- S                                                        |
+-----------------------------------------------------------------------------+
|i6 : f_0                                                                     |
|                                                                             |
|o6 = | 24 |                                                                  |
|                                                                             |
|             1       1                                                       |
|o6 : Matrix S  <--- S                                                        |
+-----------------------------------------------------------------------------+

Indices that are outside of the concentration are automatically zero.

+--------------------------------------------------------------------+
|i7 : concentration f                                                |
|                                                                    |
|o7 = (0, 3)                                                         |
|                                                                    |
|o7 : Sequence                                                       |
+--------------------------------------------------------------------+
|i8 : f_-1                                                           |
|                                                                    |
|o8 = 0                                                              |
|                                                                    |
|o8 : Matrix 0 <--- 0                                                |
+--------------------------------------------------------------------+
|i9 : f_3                                                            |
|                                                                    |
|o9 = {3} | 33a3-49a2b-19ab2+44b3-33a2c+17abc-39b2c-20ac2+36bc2+9c3 ||
|                                                                    |
|             1       1                                              |
|o9 : Matrix S  <--- S                                               |
+--------------------------------------------------------------------+
|i10 : f_4                                                           |
|                                                                    |
|o10 = 0                                                             |
|                                                                    |
|o10 : Matrix 0 <--- 0                                               |
+--------------------------------------------------------------------+

See also
========

  * Complex _ ZZ -- access individual object in a
    complex
  * concentration(ComplexMap) -- indices
    on which a complex map may be non-zero

Ways to use this method:
========================

  * ComplexMap _ ZZ -- access individual matrices in
    a complex map

ComplexMap | ComplexMap -- join or concatenate maps horizontally
****************************************************************

Synopsis
========

  * Operator: | (Macaulay2Doc),
  * Usage:
        f | g
  * Inputs:
      * f, a map of complexes,
      * g, a map of complexes,
  * Outputs:
      * a map of complexes,

Description
===========

Given complex maps with the same target, this method constructs the associated
map from the direct sum of the sources to the target.

First, we define some non-trivial maps of chain complexes.

+---------------------------------------------------------------------------+
|i1 : R = ZZ/101[a..d];                                                     |
+---------------------------------------------------------------------------+
|i2 : C1 = (freeResolution coker matrix{{a,b,c}})[1]                        |
|                                                                           |
|      1      3      3      1                                               |
|o2 = R  <-- R  <-- R  <-- R                                                |
|                                                                           |
|     -1     0      1      2                                                |
|                                                                           |
|o2 : Complex                                                               |
+---------------------------------------------------------------------------+
|i3 : C2 = freeResolution coker matrix{{a*b,a*c,b*c}}                       |
|                                                                           |
|      1      3      2                                                      |
|o3 = R  <-- R  <-- R                                                       |
|                                                                           |
|     0      1      2                                                       |
|                                                                           |
|o3 : Complex                                                               |
+---------------------------------------------------------------------------+
|i4 : D = freeResolution coker matrix{{a^2,b^2,c*d}}                        |
|                                                                           |
|      1      3      3      1                                               |
|o4 = R  <-- R  <-- R  <-- R                                                |
|                                                                           |
|     0      1      2      3                                                |
|                                                                           |
|o4 : Complex                                                               |
+---------------------------------------------------------------------------+
|i5 : f = randomComplexMap(D, C1)                                           |
|                                                                           |
|                    1                                                      |
|o5 = -1 : 0 <----- R  : -1                                                 |
|               0                                                           |
|                                                                           |
|          1                                                           3    |
|     0 : R  <------------------------------------------------------- R  : 0|
|               | 24a-36b-30c-29d 19a+19b-10c-29d -8a-22b-29c-24d |         |
|                                                                           |
|          3                          3                                     |
|     1 : R  <---------------------- R  : 1                                 |
|               {2} | -38 21 -47 |                                          |
|               {2} | -16 34 -39 |                                          |
|               {2} | 39  19 -18 |                                          |
|                                                                           |
|          3         1                                                      |
|     2 : R  <----- R  : 2                                                  |
|               0                                                           |
|                                                                           |
|o5 : ComplexMap                                                            |
+---------------------------------------------------------------------------+
|i6 : g = randomComplexMap(D, C2)                                           |
|                                                                           |
|          1               1                                                |
|o6 = 0 : R  <----------- R  : 0                                            |
|               | -13 |                                                     |
|                                                                           |
|          3                          3                                     |
|     1 : R  <---------------------- R  : 1                                 |
|               {2} | -43 -47 16 |                                          |
|               {2} | -15 38  22 |                                          |
|               {2} | -28 2   45 |                                          |
|                                                                           |
|          3         2                                                      |
|     2 : R  <----- R  : 2                                                  |
|               0                                                           |
|                                                                           |
|o6 : ComplexMap                                                            |
+---------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i7 : h = f|g                                                                 |
|                                                                             |
|          1                                                               4  |
|o7 = 0 : R  <----------------------------------------------------------- R  :|
|               | 24a-36b-30c-29d 19a+19b-10c-29d -8a-22b-29c-24d -13 |       |
|                                                                             |
|          3                                     6                            |
|     1 : R  <--------------------------------- R  : 1                        |
|               {2} | -38 21 -47 -43 -47 16 |                                 |
|               {2} | -16 34 -39 -15 38  22 |                                 |
|               {2} | 39  19 -18 -28 2   45 |                                 |
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|0                                                                            |
+-----------------------------------------------------------------------------+
|i8 : assert isWellDefined h                                                  |
+-----------------------------------------------------------------------------+
|i9 : assert(source h === source f ++ source g)                               |
+-----------------------------------------------------------------------------+
|i10 : assert(target h === target f)                                          |
+-----------------------------------------------------------------------------+

This is really a shorthand for constructing complex maps via block matrices.

+---------------------------------------------+
|i11 : assert(h === map(D, C1 ++ C2, {{f,g}}))|
+---------------------------------------------+

See also
========

  * Complex ++ Complex -- direct sum of
    complexes
  * ComplexMap ++ ComplexMap -- direct sum of
    complex maps
  * ComplexMap || ComplexMap -- join or
    concatenate maps vertically
  * Matrix | Matrix (Macaulay2Doc) -- join matrices
    horizontally
  * map(Complex,Complex,List) -- make
    a map of chain complexes

Ways to use this method:
========================

  * ComplexMap | ComplexMap -- join or
    concatenate maps horizontally

ComplexMap || ComplexMap -- join or concatenate maps vertically
***************************************************************

Synopsis
========

  * Operator: || (Macaulay2Doc),
  * Usage:
        f || g
  * Inputs:
      * f, a map of complexes,
      * g, a map of complexes,
  * Outputs:
      * a map of complexes,

Description
===========

Given complex maps with the same source, this method constructs the associated
map from the source to the direct sum of the targets.

First, we define some non-trivial maps of chain complexes.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a..d];                                                       |
+-----------------------------------------------------------------------------+
|i2 : D1 = (freeResolution coker matrix{{a,b,c}})[1]                          |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     -1     0      1      2                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : D2 = freeResolution coker matrix{{a*b,a*c,b*c}}                         |
|                                                                             |
|      1      3      2                                                        |
|o3 = R  <-- R  <-- R                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : C = freeResolution coker matrix{{a^2,b^2,c*d}}                          |
|                                                                             |
|      1      3      3      1                                                 |
|o4 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o4 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i5 : f = randomComplexMap(D1, C)                                             |
|                                                                             |
|          3         1                                                        |
|o5 = 0 : R  <----- R  : 0                                                    |
|               0                                                             |
|                                                                             |
|          3                           3                                      |
|     1 : R  <----------------------- R  : 1                                  |
|               {2} | 24  -29 -10 |                                           |
|               {2} | -36 19  -29 |                                           |
|               {2} | -30 19  -8  |                                           |
|                                                                             |
|          1                                                                 3|
|     2 : R  <------------------------------------------------------------- R |
|               {3} | -22a-29b-24c-38d -16a+39b+21c+34d 19a-47b-39c-18d |     |
|                                                                             |
|                   1                                                         |
|     3 : 0 <----- R  : 3                                                     |
|              0                                                              |
|                                                                             |
|o5 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|: 2                                                                          |
+-----------------------------------------------------------------------------+
|i6 : g = randomComplexMap(D2, C)                                             |
|                                                                             |
|          1               1                                                  |
|o6 = 0 : R  <----------- R  : 0                                              |
|               | -13 |                                                       |
|                                                                             |
|          3                          3                                       |
|     1 : R  <---------------------- R  : 1                                   |
|               {2} | -43 -47 16 |                                            |
|               {2} | -15 38  22 |                                            |
|               {2} | -28 2   45 |                                            |
|                                                                             |
|          2                                                                 3|
|     2 : R  <------------------------------------------------------------- R |
|               {3} | -34a-48b-47c+47d -23a+39b+43c-17d 11a-38b+33c+40d |     |
|               {3} | 19a-16b+7c+15d   -11a+48b+36c+35d 11a+46b-28c+d   |     |
|                                                                             |
|                   1                                                         |
|     3 : 0 <----- R  : 3                                                     |
|              0                                                              |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|: 2                                                                          |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i7 : h = f||g                                                                |
|                                                                             |
|          4                   1                                              |
|o7 = 0 : R  <--------------- R  : 0                                          |
|               {1} | 0   |                                                   |
|               {1} | 0   |                                                   |
|               {1} | 0   |                                                   |
|               {0} | -13 |                                                   |
|                                                                             |
|          6                           3                                      |
|     1 : R  <----------------------- R  : 1                                  |
|               {2} | 24  -29 -10 |                                           |
|               {2} | -36 19  -29 |                                           |
|               {2} | -30 19  -8  |                                           |
|               {2} | -43 -47 16  |                                           |
|               {2} | -15 38  22  |                                           |
|               {2} | -28 2   45  |                                           |
|                                                                             |
|          3                                                                 3|
|     2 : R  <------------------------------------------------------------- R |
|               {3} | -22a-29b-24c-38d -16a+39b+21c+34d 19a-47b-39c-18d |     |
|               {3} | -34a-48b-47c+47d -23a+39b+43c-17d 11a-38b+33c+40d |     |
|               {3} | 19a-16b+7c+15d   -11a+48b+36c+35d 11a+46b-28c+d   |     |
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|: 2                                                                          |
+-----------------------------------------------------------------------------+
|i8 : assert isWellDefined h                                                  |
+-----------------------------------------------------------------------------+
|i9 : assert(target h === target f ++ target g)                               |
+-----------------------------------------------------------------------------+
|i10 : assert(source h === source f)                                          |
+-----------------------------------------------------------------------------+

This is really a shorthand for constructing complex maps via block matrices.

+-----------------------------------------------+
|i11 : assert(h === map(D1 ++ D2, C, {{f},{g}}))|
+-----------------------------------------------+

See also
========

  * Complex ++ Complex -- direct sum of
    complexes
  * ComplexMap ++ ComplexMap -- direct sum of
    complex maps
  * ComplexMap | ComplexMap -- join or
    concatenate maps horizontally
  * Matrix || Matrix (Macaulay2Doc) -- join matrices
    vertically
  * map(Complex,Complex,List) -- make
    a map of chain complexes

Ways to use this method:
========================

  * ComplexMap || ComplexMap -- join or
    concatenate maps vertically

components(Complex) -- list the components of a direct sum
**********************************************************

Synopsis
========

  * Function: components (Macaulay2Doc),
  * Usage:
        components C
  * Inputs:
      * C, a complex,
  * Outputs:
      * a list (Macaulay2Doc), the component complexes of a direct
        sum (of complexes)

Description
===========

A complex which has been constructed as a direct sum stores its component
complexes.

+-----------------------------------------------+
|i1 : S = ZZ/101[a,b,c];                        |
+-----------------------------------------------+
|i2 : C1 = freeResolution coker vars S          |
|                                               |
|      1      3      3      1                   |
|o2 = S  <-- S  <-- S  <-- S                    |
|                                               |
|     0      1      2      3                    |
|                                               |
|o2 : Complex                                   |
+-----------------------------------------------+
|i3 : C2 = complex (ideal(a,b,c))               |
|                                               |
|o3 = image | a b c |                           |
|                                               |
|     0                                         |
|                                               |
|o3 : Complex                                   |
+-----------------------------------------------+
|i4 : D = C1 ++ C2                              |
|                                               |
|                            3      3      1    |
|o4 = image | 1 0 0 0 | <-- S  <-- S  <-- S     |
|           | 0 a b c |                         |
|                           1      2      3     |
|     0                                         |
|                                               |
|o4 : Complex                                   |
+-----------------------------------------------+
|i5 : L = components D                          |
|                                               |
|       1      3      3      1                  |
|o5 = {S  <-- S  <-- S  <-- S , image | a b c |}|
|                                               |
|      0      1      2      3   0               |
|                                               |
|o5 : List                                      |
+-----------------------------------------------+
|i6 : L_0 === C1                                |
|                                               |
|o6 = true                                      |
+-----------------------------------------------+
|i7 : L_1 === C2                                |
|                                               |
|o7 = true                                      |
+-----------------------------------------------+
|i8 : E = (mike => C1) ++ (greg => C2)          |
|                                               |
|                            3      3      1    |
|o8 = image | 1 0 0 0 | <-- S  <-- S  <-- S     |
|           | 0 a b c |                         |
|                           1      2      3     |
|     0                                         |
|                                               |
|o8 : Complex                                   |
+-----------------------------------------------+
|i9 : components E                              |
|                                               |
|       1      3      3      1                  |
|o9 = {S  <-- S  <-- S  <-- S , image | a b c |}|
|                                               |
|      0      1      2      3   0               |
|                                               |
|o9 : List                                      |
+-----------------------------------------------+

The names of the component complexes are called indices, and are used to access
the relevant inclusion and projection maps.

+------------------------------------------------------------------+
|i10 : indices D                                                   |
|                                                                  |
|o10 = {0, 1}                                                      |
|                                                                  |
|o10 : List                                                        |
+------------------------------------------------------------------+
|i11 : D^[0]                                                       |
|                                                                  |
|           1                                                      |
|o11 = 0 : S  <--------------- image | 1 0 0 0 | : 0               |
|                | 1 0 0 0 |         | 0 a b c |                   |
|                                                                  |
|           3                     3                                |
|      1 : S  <----------------- S  : 1                            |
|                {1} | 1 0 0 |                                     |
|                {1} | 0 1 0 |                                     |
|                {1} | 0 0 1 |                                     |
|                                                                  |
|           3                     3                                |
|      2 : S  <----------------- S  : 2                            |
|                {2} | 1 0 0 |                                     |
|                {2} | 0 1 0 |                                     |
|                {2} | 0 0 1 |                                     |
|                                                                  |
|           1                 1                                    |
|      3 : S  <------------- S  : 3                                |
|                {3} | 1 |                                         |
|                                                                  |
|o11 : ComplexMap                                                  |
+------------------------------------------------------------------+
|i12 : indices E                                                   |
|                                                                  |
|o12 = {mike, greg}                                                |
|                                                                  |
|o12 : List                                                        |
+------------------------------------------------------------------+
|i13 : E_[greg]                                                    |
|                                                                  |
|o13 = 0 : image | 1 0 0 0 | <----------------- image | a b c | : 0|
|                | 0 a b c |    {0} | 0 0 0 |                      |
|                               {1} | 1 0 0 |                      |
|                               {1} | 0 1 0 |                      |
|                               {1} | 0 0 1 |                      |
|                                                                  |
|o13 : ComplexMap                                                  |
+------------------------------------------------------------------+

See also
========

  * directSum(Complex) -- direct sum of
    complexes
  * indices (Macaulay2Doc) -- indices of a polynomial; also
    components for a direct sum
  * Complex _ Array -- the canonical inclusion or
    projection map of a direct sum
  * Complex ^ Array -- the canonical inclusion or
    projection map of a direct sum

Ways to use this method:
========================

  * components(Complex) -- list the components
    of a direct sum

components(ComplexMap) -- list the components of a direct sum
*************************************************************

Synopsis
========

  * Function: components (Macaulay2Doc),
  * Usage:
        components f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * a list (Macaulay2Doc), the component maps of a direct sum
        of maps of complexes

Description
===========

A map of complexes stores its component maps.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c];                                                      |
+-----------------------------------------------------------------------------+
|i2 : C = freeResolution coker vars S                                         |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : g1 = id_C                                                               |
|                                                                             |
|          1             1                                                    |
|o3 = 0 : S  <--------- S  : 0                                                |
|               | 1 |                                                         |
|                                                                             |
|          3                     3                                            |
|     1 : S  <----------------- S  : 1                                        |
|               {1} | 1 0 0 |                                                 |
|               {1} | 0 1 0 |                                                 |
|               {1} | 0 0 1 |                                                 |
|                                                                             |
|          3                     3                                            |
|     2 : S  <----------------- S  : 2                                        |
|               {2} | 1 0 0 |                                                 |
|               {2} | 0 1 0 |                                                 |
|               {2} | 0 0 1 |                                                 |
|                                                                             |
|          1                 1                                                |
|     3 : S  <------------- S  : 3                                            |
|               {3} | 1 |                                                     |
|                                                                             |
|o3 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i4 : g2 = randomComplexMap(C[1], C[2], Boundary => true)                     |
|                                                                             |
|                    1                                                        |
|o4 = -2 : 0 <----- S  : -2                                                   |
|               0                                                             |
|                                                                             |
|           1                                               3                 |
|     -1 : S  <------------------------------------------- S  : -1            |
|                | -41a+30b+29c -19a+5b+10c 29a+8b+46c |                      |
|                                                                             |
|          3                                                     3            |
|     0 : S  <------------------------------------------------- S  : 0        |
|               {1} | 19a+7b-24c  -29a-16b-26c 5b           |                 |
|               {1} | 48a+30b-38c 8a-50c       -34a-8b+35c  |                 |
|               {1} | 14a-34b     40a-21b+29c  -19a+25b+10c |                 |
|                                                                             |
|          3                            1                                     |
|     1 : S  <------------------------ S  : 1                                 |
|               {2} | 34a+16b-29c  |                                          |
|               {2} | 19a-39b-24c  |                                          |
|               {2} | -47a-21b-38c |                                          |
|                                                                             |
|o4 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i5 : f = g1 ++ g2                                                            |
|                                                                             |
|                    1                                                        |
|o5 = -2 : 0 <----- S  : -2                                                   |
|               0                                                             |
|                                                                             |
|           1                                               3                 |
|     -1 : S  <------------------------------------------- S  : -1            |
|                | -41a+30b+29c -19a+5b+10c 29a+8b+46c |                      |
|                                                                             |
|          4                                                       4          |
|     0 : S  <--------------------------------------------------- S  : 0      |
|               {0} | 1 0           0            0            |               |
|               {1} | 0 19a+7b-24c  -29a-16b-26c 5b           |               |
|               {1} | 0 48a+30b-38c 8a-50c       -34a-8b+35c  |               |
|               {1} | 0 14a-34b     40a-21b+29c  -19a+25b+10c |               |
|                                                                             |
|          6                                  4                               |
|     1 : S  <------------------------------ S  : 1                           |
|               {1} | 1 0 0 0            |                                    |
|               {1} | 0 1 0 0            |                                    |
|               {1} | 0 0 1 0            |                                    |
|               {2} | 0 0 0 34a+16b-29c  |                                    |
|               {2} | 0 0 0 19a-39b-24c  |                                    |
|               {2} | 0 0 0 -47a-21b-38c |                                    |
|                                                                             |
|          4                     3                                            |
|     2 : S  <----------------- S  : 2                                        |
|               {2} | 1 0 0 |                                                 |
|               {2} | 0 1 0 |                                                 |
|               {2} | 0 0 1 |                                                 |
|               {3} | 0 0 0 |                                                 |
|                                                                             |
|          1                 1                                                |
|     3 : S  <------------- S  : 3                                            |
|               {3} | 1 |                                                     |
|                                                                             |
|o5 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i6 : assert isWellDefined f                                                  |
+-----------------------------------------------------------------------------+
|i7 : L = components f                                                        |
|                                                                             |
|           1             1                                                   |
|o7 = {0 : S  <--------- S  : 0        ,                                      |
|                | 1 |                                                        |
|                                                                             |
|           3                     3                                           |
|      1 : S  <----------------- S  : 1                                       |
|                {1} | 1 0 0 |                                                |
|                {1} | 0 1 0 |                                                |
|                {1} | 0 0 1 |                                                |
|                                                                             |
|           3                     3                                           |
|      2 : S  <----------------- S  : 2                                       |
|                {2} | 1 0 0 |                                                |
|                {2} | 0 1 0 |                                                |
|                {2} | 0 0 1 |                                                |
|                                                                             |
|           1                 1                                               |
|      3 : S  <------------- S  : 3                                           |
|                {3} | 1 |                                                    |
|     ------------------------------------------------------------------------|
|                    1                                                        |
|     -2 : 0 <----- S  : -2                                           }       |
|               0                                                             |
|                                                                             |
|           1                                               3                 |
|     -1 : S  <------------------------------------------- S  : -1            |
|                | -41a+30b+29c -19a+5b+10c 29a+8b+46c |                      |
|                                                                             |
|          3                                                     3            |
|     0 : S  <------------------------------------------------- S  : 0        |
|               {1} | 19a+7b-24c  -29a-16b-26c 5b           |                 |
|               {1} | 48a+30b-38c 8a-50c       -34a-8b+35c  |                 |
|               {1} | 14a-34b     40a-21b+29c  -19a+25b+10c |                 |
|                                                                             |
|          3                            1                                     |
|     1 : S  <------------------------ S  : 1                                 |
|               {2} | 34a+16b-29c  |                                          |
|               {2} | 19a-39b-24c  |                                          |
|               {2} | -47a-21b-38c |                                          |
|                                                                             |
|o7 : List                                                                    |
+-----------------------------------------------------------------------------+
|i8 : L_0 === g1                                                              |
|                                                                             |
|o8 = true                                                                    |
+-----------------------------------------------------------------------------+
|i9 : L_1 === g2                                                              |
|                                                                             |
|o9 = true                                                                    |
+-----------------------------------------------------------------------------+
|i10 : indices f                                                              |
|                                                                             |
|o10 = {0, 1}                                                                 |
|                                                                             |
|o10 : List                                                                   |
+-----------------------------------------------------------------------------+
|i11 : f' = (greg => g1) ++ (mike => g2)                                      |
|                                                                             |
|                     1                                                       |
|o11 = -2 : 0 <----- S  : -2                                                  |
|                0                                                            |
|                                                                             |
|            1                                               3                |
|      -1 : S  <------------------------------------------- S  : -1           |
|                 | -41a+30b+29c -19a+5b+10c 29a+8b+46c |                     |
|                                                                             |
|           4                                                       4         |
|      0 : S  <--------------------------------------------------- S  : 0     |
|                {0} | 1 0           0            0            |              |
|                {1} | 0 19a+7b-24c  -29a-16b-26c 5b           |              |
|                {1} | 0 48a+30b-38c 8a-50c       -34a-8b+35c  |              |
|                {1} | 0 14a-34b     40a-21b+29c  -19a+25b+10c |              |
|                                                                             |
|           6                                  4                              |
|      1 : S  <------------------------------ S  : 1                          |
|                {1} | 1 0 0 0            |                                   |
|                {1} | 0 1 0 0            |                                   |
|                {1} | 0 0 1 0            |                                   |
|                {2} | 0 0 0 34a+16b-29c  |                                   |
|                {2} | 0 0 0 19a-39b-24c  |                                   |
|                {2} | 0 0 0 -47a-21b-38c |                                   |
|                                                                             |
|           4                     3                                           |
|      2 : S  <----------------- S  : 2                                       |
|                {2} | 1 0 0 |                                                |
|                {2} | 0 1 0 |                                                |
|                {2} | 0 0 1 |                                                |
|                {3} | 0 0 0 |                                                |
|                                                                             |
|           1                 1                                               |
|      3 : S  <------------- S  : 3                                           |
|                {3} | 1 |                                                    |
|                                                                             |
|o11 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i12 : components f'                                                          |
|                                                                             |
|            1             1                                                  |
|o12 = {0 : S  <--------- S  : 0        ,                                     |
|                 | 1 |                                                       |
|                                                                             |
|            3                     3                                          |
|       1 : S  <----------------- S  : 1                                      |
|                 {1} | 1 0 0 |                                               |
|                 {1} | 0 1 0 |                                               |
|                 {1} | 0 0 1 |                                               |
|                                                                             |
|            3                     3                                          |
|       2 : S  <----------------- S  : 2                                      |
|                 {2} | 1 0 0 |                                               |
|                 {2} | 0 1 0 |                                               |
|                 {2} | 0 0 1 |                                               |
|                                                                             |
|            1                 1                                              |
|       3 : S  <------------- S  : 3                                          |
|                 {3} | 1 |                                                   |
|      -----------------------------------------------------------------------|
|                     1                                                       |
|      -2 : 0 <----- S  : -2                                           }      |
|                0                                                            |
|                                                                             |
|            1                                               3                |
|      -1 : S  <------------------------------------------- S  : -1           |
|                 | -41a+30b+29c -19a+5b+10c 29a+8b+46c |                     |
|                                                                             |
|           3                                                     3           |
|      0 : S  <------------------------------------------------- S  : 0       |
|                {1} | 19a+7b-24c  -29a-16b-26c 5b           |                |
|                {1} | 48a+30b-38c 8a-50c       -34a-8b+35c  |                |
|                {1} | 14a-34b     40a-21b+29c  -19a+25b+10c |                |
|                                                                             |
|           3                            1                                    |
|      1 : S  <------------------------ S  : 1                                |
|                {2} | 34a+16b-29c  |                                         |
|                {2} | 19a-39b-24c  |                                         |
|                {2} | -47a-21b-38c |                                         |
|                                                                             |
|o12 : List                                                                   |
+-----------------------------------------------------------------------------+
|i13 : indices f'                                                             |
|                                                                             |
|o13 = {greg, mike}                                                           |
|                                                                             |
|o13 : List                                                                   |
+-----------------------------------------------------------------------------+

The names of the components are called indices, and are used to access the
relevant inclusion and projection maps.

+----------------------------------------------------------------------+
|i14 : f'_[mike]                                                       |
|                                                                      |
|            1                                               3         |
|o14 = -1 : S  <------------------------------------------- S  : -1    |
|                 | -41a+30b+29c -19a+5b+10c 29a+8b+46c |              |
|                                                                      |
|           4                                                     3    |
|      0 : S  <------------------------------------------------- S  : 0|
|                {0} | 0           0            0            |         |
|                {1} | 19a+7b-24c  -29a-16b-26c 5b           |         |
|                {1} | 48a+30b-38c 8a-50c       -34a-8b+35c  |         |
|                {1} | 14a-34b     40a-21b+29c  -19a+25b+10c |         |
|                                                                      |
|           6                            1                             |
|      1 : S  <------------------------ S  : 1                         |
|                {1} | 0            |                                  |
|                {1} | 0            |                                  |
|                {1} | 0            |                                  |
|                {2} | 34a+16b-29c  |                                  |
|                {2} | 19a-39b-24c  |                                  |
|                {2} | -47a-21b-38c |                                  |
|                                                                      |
|o14 : ComplexMap                                                      |
+----------------------------------------------------------------------+
|i15 : f'^[greg]                                                       |
|                                                                      |
|           1                   4                                      |
|o15 = 0 : S  <--------------- S  : 0                                  |
|                | 1 0 0 0 |                                           |
|                                                                      |
|           3                       4                                  |
|      1 : S  <------------------- S  : 1                              |
|                {1} | 1 0 0 0 |                                       |
|                {1} | 0 1 0 0 |                                       |
|                {1} | 0 0 1 0 |                                       |
|                                                                      |
|           3                     3                                    |
|      2 : S  <----------------- S  : 2                                |
|                {2} | 1 0 0 |                                         |
|                {2} | 0 1 0 |                                         |
|                {2} | 0 0 1 |                                         |
|                                                                      |
|           1                 1                                        |
|      3 : S  <------------- S  : 3                                    |
|                {3} | 1 |                                             |
|                                                                      |
|o15 : ComplexMap                                                      |
+----------------------------------------------------------------------+
|i16 : f^[0]                                                           |
|                                                                      |
|           1                   4                                      |
|o16 = 0 : S  <--------------- S  : 0                                  |
|                | 1 0 0 0 |                                           |
|                                                                      |
|           3                       4                                  |
|      1 : S  <------------------- S  : 1                              |
|                {1} | 1 0 0 0 |                                       |
|                {1} | 0 1 0 0 |                                       |
|                {1} | 0 0 1 0 |                                       |
|                                                                      |
|           3                     3                                    |
|      2 : S  <----------------- S  : 2                                |
|                {2} | 1 0 0 |                                         |
|                {2} | 0 1 0 |                                         |
|                {2} | 0 0 1 |                                         |
|                                                                      |
|           1                 1                                        |
|      3 : S  <------------- S  : 3                                    |
|                {3} | 1 |                                             |
|                                                                      |
|o16 : ComplexMap                                                      |
+----------------------------------------------------------------------+
|i17 : f_[0]                                                           |
|                                                                      |
|           4                 1                                        |
|o17 = 0 : S  <------------- S  : 0                                    |
|                {0} | 1 |                                             |
|                {1} | 0 |                                             |
|                {1} | 0 |                                             |
|                {1} | 0 |                                             |
|                                                                      |
|           6                     3                                    |
|      1 : S  <----------------- S  : 1                                |
|                {1} | 1 0 0 |                                         |
|                {1} | 0 1 0 |                                         |
|                {1} | 0 0 1 |                                         |
|                {2} | 0 0 0 |                                         |
|                {2} | 0 0 0 |                                         |
|                {2} | 0 0 0 |                                         |
|                                                                      |
|           4                     3                                    |
|      2 : S  <----------------- S  : 2                                |
|                {2} | 1 0 0 |                                         |
|                {2} | 0 1 0 |                                         |
|                {2} | 0 0 1 |                                         |
|                {3} | 0 0 0 |                                         |
|                                                                      |
|           1                 1                                        |
|      3 : S  <------------- S  : 3                                    |
|                {3} | 1 |                                             |
|                                                                      |
|o17 : ComplexMap                                                      |
+----------------------------------------------------------------------+

See also
========

  * directSum(ComplexMap) -- direct sum of
    complex maps
  * components(Complex) -- list the components
    of a direct sum
  * indices (Macaulay2Doc) -- indices of a polynomial; also
    components for a direct sum
  * ComplexMap _ Array -- the composition with the
    canonical inclusion or projection map
  * ComplexMap ^ Array -- the composition with the
    canonical inclusion or projection map

Ways to use this method:
========================

  * components(ComplexMap) -- list the
    components of a direct sum

Concentration -- optional argument used to specify the concentration
********************************************************************

Description
===========

In this package, each complex $C$ has a concentration $(\ell, h)$ such that
$\ell \leq h$.  For all $i < \ell$ and all $i > h$, the term $C_i$ is zero.
When $\ell \leq i \leq h$, the module $C_i$ may or may not be zero.

Several methods use this optional argument to specify the concentration of
their outputs.

See also
========

  * concentration(Complex) -- indices on which a complex
    may be non-zero

Functions with optional argument named Concentration :
======================================================

  * "connectingExtMap(...,Concentration=>...)" -- see
    connectingExtMap(Module,Matrix,Matrix),
    -- makes the connecting
    maps in Ext
  * "connectingMap(...,Concentration=>...)" -- see
    connectingMap(ComplexMap,ComplexMap),
    -- construct the connecting
    homomorphism on homology
  * "connectingTorMap(...,Concentration=>...)" -- see
    connectingTorMap(Module,Matrix,Matrix),
    -- makes the connecting
    maps in Tor
  * "isQuasiIsomorphism(...,Concentration=>...)" -- see
    isQuasiIsomorphism(ComplexMap), --
    whether a map of complexes is a quasi-isomorphism
  * "koszulComplex(List,Concentration=>...)" -- see
    koszulComplex(Matrix), -- makes the Koszul
    complex
  * "koszulComplex(Matrix,Concentration=>...)" -- see
    koszulComplex(Matrix), -- makes the Koszul
    complex
  * "longExactSequence(ComplexMap,ComplexMap,Concentration=>...)" -- see
    longExactSequence(ComplexMap,ComplexMap),
    -- make the long exact
    sequence in homology

For the programmer
==================

The object Concentration, is a symbol (Macaulay2Doc).

concentration -- indices on which a complex may be non-zero
***********************************************************

Synopsis
========

  * Usage:
        (lo,hi) = concentration C
  * Inputs:
      * C, a complex,
  * Outputs:
      * lo, an integer (Macaulay2Doc),
      * hi, an integer (Macaulay2Doc), a pair of integers lo, hi such
        that C_i = 0 for i < lo or i > hi.

Description
===========

In this package, each complex has a concentration (lo, hi) such that lo <= hi.
When lo <= i <= hi, the module C_i might be zero.  The methods max and min
applied to the complex C return lo and hi, respectively.

This function is mainly used in programming, to loop over all non-zero modules
or maps in the complex.  This should not be confused with the support of a
complex.

+---------------------------------------------------------------+
|i1 : S = ZZ/101[a..c];                                         |
+---------------------------------------------------------------+
|i2 : C = freeResolution coker vars S                           |
|                                                               |
|      1      3      3      1                                   |
|o2 = S  <-- S  <-- S  <-- S                                    |
|                                                               |
|     0      1      2      3                                    |
|                                                               |
|o2 : Complex                                                   |
+---------------------------------------------------------------+
|i3 : concentration C                                           |
|                                                               |
|o3 = (0, 3)                                                    |
|                                                               |
|o3 : Sequence                                                  |
+---------------------------------------------------------------+
|i4 : D = C ++ C[5]                                             |
|                                                               |
|      1      3      3      1             1      3      3      1|
|o4 = S  <-- S  <-- S  <-- S  <-- 0  <-- S  <-- S  <-- S  <-- S |
|                                                               |
|     -5     -4     -3     -2     -1     0      1      2      3 |
|                                                               |
|o4 : Complex                                                   |
+---------------------------------------------------------------+
|i5 : concentration D                                           |
|                                                               |
|o5 = (-5, 3)                                                   |
|                                                               |
|o5 : Sequence                                                  |
+---------------------------------------------------------------+
|i6 : min D                                                     |
|                                                               |
|o6 = -5                                                        |
+---------------------------------------------------------------+
|i7 : max D                                                     |
|                                                               |
|o7 = 3                                                         |
+---------------------------------------------------------------+
|i8 : assert((min D, max D) === concentration D)                |
+---------------------------------------------------------------+

Indices that are outside of the concentration automatically return the zero
object.

+--------------+
|i9 : C_-1     |
|              |
|o9 = 0        |
|              |
|o9 : S-module |
+--------------+
|i10 : D_4     |
|              |
|o10 = 0       |
|              |
|o10 : S-module|
+--------------+

The function concentration does no computation. To eliminate extraneous zeros,
use prune(Complex).

+-------------------------------------------------+
|i11 : f1 = a*id_C                                |
|                                                 |
|           1             1                       |
|o11 = 0 : S  <--------- S  : 0                   |
|                | a |                            |
|                                                 |
|           3                     3               |
|      1 : S  <----------------- S  : 1           |
|                {1} | a 0 0 |                    |
|                {1} | 0 a 0 |                    |
|                {1} | 0 0 a |                    |
|                                                 |
|           3                     3               |
|      2 : S  <----------------- S  : 2           |
|                {2} | a 0 0 |                    |
|                {2} | 0 a 0 |                    |
|                {2} | 0 0 a |                    |
|                                                 |
|           1                 1                   |
|      3 : S  <------------- S  : 3               |
|                {3} | a |                        |
|                                                 |
|o11 : ComplexMap                                 |
+-------------------------------------------------+
|i12 : E = ker f1                                 |
|                                                 |
|o12 = image 0 <-- image 0 <-- image 0 <-- image 0|
|                                                 |
|      0           1           2           3      |
|                                                 |
|o12 : Complex                                    |
+-------------------------------------------------+
|i13 : concentration E                            |
|                                                 |
|o13 = (0, 3)                                     |
|                                                 |
|o13 : Sequence                                   |
+-------------------------------------------------+
|i14 : concentration prune E                      |
|                                                 |
|o14 = (0, 0)                                     |
|                                                 |
|o14 : Sequence                                   |
+-------------------------------------------------+

The concentration of a zero complex can be arbitrary, however, after pruning,
its concentration will be (0,0).

+---------------------------+
|i15 : C0 = (complex S^0)[4]|
|                           |
|o15 = 0                    |
|                           |
|      -4                   |
|                           |
|o15 : Complex              |
+---------------------------+
|i16 : concentration C0     |
|                           |
|o16 = (-4, -4)             |
|                           |
|o16 : Sequence             |
+---------------------------+
|i17 : prune C0             |
|                           |
|o17 = 0                    |
|                           |
|      0                    |
|                           |
|o17 : Complex              |
+---------------------------+
|i18 : concentration oo     |
|                           |
|o18 = (0, 0)               |
|                           |
|o18 : Sequence             |
+---------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * Complex _ ZZ -- access individual object in a
    complex
  * concentration(ComplexMap) -- indices
    on which a complex map may be non-zero

Ways to use concentration :
===========================

  * "concentration(Complex)"
  * concentration(ComplexMap) -- indices
    on which a complex map may be non-zero

For the programmer
==================

The object concentration, is a method function (Macaulay2Doc).

concentration(ComplexMap) -- indices on which a complex map may be non-zero
***************************************************************************

Synopsis
========

  * Function: concentration,
  * Usage:
        (lo,hi) = concentration f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * a sequence (Macaulay2Doc), a pair of integers lo, hi
        such that f_i = 0 for i < lo or i > hi.

Description
===========

In this package, each map of complexes has a concentration (lo, hi) such that
lo <= hi.  When lo <= i <= hi, the map f_i might be zero.

This function is mainly used in programming, to loop over all non-zero maps.
This should not be confused with the support of the source or target.

+---------------------------------------------------------------+
|i1 : S = ZZ/101[a..c]                                          |
|                                                               |
|o1 = S                                                         |
|                                                               |
|o1 : PolynomialRing                                            |
+---------------------------------------------------------------+
|i2 : C = freeResolution coker vars S                           |
|                                                               |
|      1      3      3      1                                   |
|o2 = S  <-- S  <-- S  <-- S                                    |
|                                                               |
|     0      1      2      3                                    |
|                                                               |
|o2 : Complex                                                   |
+---------------------------------------------------------------+
|i3 : concentration id_C                                        |
|                                                               |
|o3 = (0, 3)                                                    |
|                                                               |
|o3 : Sequence                                                  |
+---------------------------------------------------------------+
|i4 : D = C ++ C[5]                                             |
|                                                               |
|      1      3      3      1             1      3      3      1|
|o4 = S  <-- S  <-- S  <-- S  <-- 0  <-- S  <-- S  <-- S  <-- S |
|                                                               |
|     -5     -4     -3     -2     -1     0      1      2      3 |
|                                                               |
|o4 : Complex                                                   |
+---------------------------------------------------------------+
|i5 : concentration id_D                                        |
|                                                               |
|o5 = (-5, 3)                                                   |
|                                                               |
|o5 : Sequence                                                  |
+---------------------------------------------------------------+
|i6 : f = randomComplexMap(D, C)                                |
|                                                               |
|          1              1                                     |
|o6 = 0 : S  <---------- S  : 0                                 |
|               | 24 |                                          |
|                                                               |
|          3                           3                        |
|     1 : S  <----------------------- S  : 1                    |
|               {1} | -36 19  -29 |                             |
|               {1} | -30 19  -8  |                             |
|               {1} | -29 -10 -22 |                             |
|                                                               |
|          3                           3                        |
|     2 : S  <----------------------- S  : 2                    |
|               {2} | -29 -16 34  |                             |
|               {2} | -24 39  19  |                             |
|               {2} | -38 21  -47 |                             |
|                                                               |
|          1                   1                                |
|     3 : S  <--------------- S  : 3                            |
|               {3} | -39 |                                     |
|                                                               |
|o6 : ComplexMap                                                |
+---------------------------------------------------------------+
|i7 : concentration f                                           |
|                                                               |
|o7 = (0, 3)                                                    |
|                                                               |
|o7 : Sequence                                                  |
+---------------------------------------------------------------+

Indices that are outside of the concentration automatically return the zero
object.

+--------------------+
|i8 : f_-1           |
|                    |
|o8 = 0              |
|                    |
|o8 : Matrix 0 <--- 0|
+--------------------+
|i9 : (id_D)_4       |
|                    |
|o9 = 0              |
|                    |
|o9 : Matrix 0 <--- 0|
+--------------------+

Maps inside the concentration may nevertheless be zero.

+---------------------+
|i10 : (id_D)_-1      |
|                     |
|o10 = 0              |
|                     |
|o10 : Matrix 0 <--- 0|
+---------------------+

The concentration of a zero complex can be arbitrary, however, after pruning,
its concentration will be (0,0).

+---------------------------+
|i11 : C0 = (complex S^0)[4]|
|                           |
|o11 = 0                    |
|                           |
|      -4                   |
|                           |
|o11 : Complex              |
+---------------------------+
|i12 : g = id_C0            |
|                           |
|o12 = -4 : 0 <----- 0 : -4 |
|                0          |
|                           |
|o12 : ComplexMap           |
+---------------------------+
|i13 : concentration g      |
|                           |
|o13 = (-4, -4)             |
|                           |
|o13 : Sequence             |
+---------------------------+
|i14 : prune g              |
|                           |
|o14 = 0                    |
|                           |
|o14 : ComplexMap           |
+---------------------------+
|i15 : concentration oo     |
|                           |
|o15 = (0, 0)               |
|                           |
|o15 : Sequence             |
+---------------------------+

See also
========

  * concentration(Complex) -- indices on which a complex
    may be non-zero
  * ComplexMap _ ZZ -- access individual matrices in
    a complex map

Ways to use this method:
========================

  * concentration(ComplexMap) -- indices
    on which a complex map may be non-zero

cone(ComplexMap) -- make the mapping cone of a morphism of chain complexes
**************************************************************************

Synopsis
========

  * Function: cone (Macaulay2Doc),
  * Usage:
        cone f
  * Inputs:
      * f, a map of complexes, which is a morphism of
        complexes
  * Outputs:
      * a complex,

Description
===========

Given a morphism $f \colon B \to C$, the mapping cone is the complex whose
$i$-th term is $B_{i-1} \oplus C_i$, and whose $i$-th differential is given by
\[ \begin{bmatrix} -\operatorname{dd}^{B[-1]} & 0 \\ f[-1] &
\operatorname{dd}^C \end{bmatrix}. \]

A map between modules induces a map between their free resolutions, and we
compute the associated mapping cone.

+----------------------------------------------------------------+
|i1 : S = ZZ/32003[x,y,z];                                       |
+----------------------------------------------------------------+
|i2 : M = ideal vars S                                           |
|                                                                |
|o2 = ideal (x, y, z)                                            |
|                                                                |
|o2 : Ideal of S                                                 |
+----------------------------------------------------------------+
|i3 : B = freeResolution(S^1/M^2)                                |
|                                                                |
|      1      6      8      3                                    |
|o3 = S  <-- S  <-- S  <-- S                                     |
|                                                                |
|     0      1      2      3                                     |
|                                                                |
|o3 : Complex                                                    |
+----------------------------------------------------------------+
|i4 : C = freeResolution(S^1/M)                                  |
|                                                                |
|      1      3      3      1                                    |
|o4 = S  <-- S  <-- S  <-- S                                     |
|                                                                |
|     0      1      2      3                                     |
|                                                                |
|o4 : Complex                                                    |
+----------------------------------------------------------------+
|i5 : f = extend(C,B,id_(S^1))                                   |
|                                                                |
|          1             1                                       |
|o5 = 0 : S  <--------- S  : 0                                   |
|               | 1 |                                            |
|                                                                |
|          3                           6                         |
|     1 : S  <----------------------- S  : 1                     |
|               {1} | x y 0 0 0 0 |                              |
|               {1} | 0 0 y 0 0 0 |                              |
|               {1} | 0 0 0 x y z |                              |
|                                                                |
|          3                               8                     |
|     2 : S  <--------------------------- S  : 2                 |
|               {2} | 0 y 0 0 0 0 0 0 |                          |
|               {2} | 0 0 x y 0 0 0 0 |                          |
|               {2} | 0 0 0 0 0 y 0 0 |                          |
|                                                                |
|          1                     3                               |
|     3 : S  <----------------- S  : 3                           |
|               {3} | 0 y 0 |                                    |
|                                                                |
|o5 : ComplexMap                                                 |
+----------------------------------------------------------------+
|i6 : Cf = cone f                                                |
|                                                                |
|      1      4      9      9      3                             |
|o6 = S  <-- S  <-- S  <-- S  <-- S                              |
|                                                                |
|     0      1      2      3      4                              |
|                                                                |
|o6 : Complex                                                    |
+----------------------------------------------------------------+
|i7 : dd^Cf                                                      |
|                                                                |
|          1                   4                                 |
|o7 = 0 : S  <--------------- S  : 1                             |
|               | 1 x y z |                                      |
|                                                                |
|          4                                                9    |
|     1 : S  <-------------------------------------------- S  : 2|
|               {0} | -x2 -xy -y2 -xz -yz -z2 0  0  0  |         |
|               {1} | x   y   0   0   0   0   -y -z 0  |         |
|               {1} | 0   0   y   0   0   0   x  0  -z |         |
|               {1} | 0   0   0   x   y   z   0  x  y  |         |
|                                                                |
|          9                                          9          |
|     2 : S  <-------------------------------------- S  : 3      |
|               {2} | y  0  z  0  0  0  0  0  0  |               |
|               {2} | -x y  0  z  0  0  0  0  0  |               |
|               {2} | 0  -x 0  0  0  z  0  0  0  |               |
|               {2} | 0  0  -x -y y  0  z  0  0  |               |
|               {2} | 0  0  0  0  -x -y 0  z  0  |               |
|               {2} | 0  0  0  0  0  0  -x -y 0  |               |
|               {2} | 0  y  0  0  0  0  0  0  z  |               |
|               {2} | 0  0  x  y  0  0  0  0  -y |               |
|               {2} | 0  0  0  0  0  y  0  0  x  |               |
|                                                                |
|          9                        3                            |
|     3 : S  <-------------------- S  : 4                        |
|               {3} | -z 0  0  |                                 |
|               {3} | 0  -z 0  |                                 |
|               {3} | y  0  0  |                                 |
|               {3} | -x y  0  |                                 |
|               {3} | 0  y  -z |                                 |
|               {3} | 0  -x 0  |                                 |
|               {3} | 0  0  y  |                                 |
|               {3} | 0  0  -x |                                 |
|               {3} | 0  y  0  |                                 |
|                                                                |
|o7 : ComplexMap                                                 |
+----------------------------------------------------------------+
|i8 : prune HH Cf                                                |
|                                                                |
|o8 = cokernel {1} | z y x 0 0 0 0 0 0 |                         |
|              {1} | 0 0 0 z y x 0 0 0 |                         |
|              {1} | 0 0 0 0 0 0 z y x |                         |
|                                                                |
|     1                                                          |
|                                                                |
|o8 : Complex                                                    |
+----------------------------------------------------------------+
|i9 : assert(prune HH_1 Cf == prune(M/M^2))                      |
+----------------------------------------------------------------+

The mapping cone fits into a canonical short exact sequence of chain complexes:
$$0 \to C \to \operatorname{cone}(f) \to B[-1] \to 0.$$

+--------------------------------------------------+
|i10 : g = canonicalMap(Cf,C)                      |
|                                                  |
|           1             1                        |
|o10 = 0 : S  <--------- S  : 0                    |
|                | 1 |                             |
|                                                  |
|           4                     3                |
|      1 : S  <----------------- S  : 1            |
|                {0} | 0 0 0 |                     |
|                {1} | 1 0 0 |                     |
|                {1} | 0 1 0 |                     |
|                {1} | 0 0 1 |                     |
|                                                  |
|           9                     3                |
|      2 : S  <----------------- S  : 2            |
|                {2} | 0 0 0 |                     |
|                {2} | 0 0 0 |                     |
|                {2} | 0 0 0 |                     |
|                {2} | 0 0 0 |                     |
|                {2} | 0 0 0 |                     |
|                {2} | 0 0 0 |                     |
|                {2} | 1 0 0 |                     |
|                {2} | 0 1 0 |                     |
|                {2} | 0 0 1 |                     |
|                                                  |
|           9                 1                    |
|      3 : S  <------------- S  : 3                |
|                {3} | 0 |                         |
|                {3} | 0 |                         |
|                {3} | 0 |                         |
|                {3} | 0 |                         |
|                {3} | 0 |                         |
|                {3} | 0 |                         |
|                {3} | 0 |                         |
|                {3} | 0 |                         |
|                {3} | 1 |                         |
|                                                  |
|o10 : ComplexMap                                  |
+--------------------------------------------------+
|i11 : h = canonicalMap(B[-1],Cf)                  |
|                                                  |
|           1                   4                  |
|o11 = 1 : S  <--------------- S  : 1              |
|                | 1 0 0 0 |                       |
|                                                  |
|           6                                 9    |
|      2 : S  <----------------------------- S  : 2|
|                {2} | 1 0 0 0 0 0 0 0 0 |         |
|                {2} | 0 1 0 0 0 0 0 0 0 |         |
|                {2} | 0 0 1 0 0 0 0 0 0 |         |
|                {2} | 0 0 0 1 0 0 0 0 0 |         |
|                {2} | 0 0 0 0 1 0 0 0 0 |         |
|                {2} | 0 0 0 0 0 1 0 0 0 |         |
|                                                  |
|           8                                 9    |
|      3 : S  <----------------------------- S  : 3|
|                {3} | 1 0 0 0 0 0 0 0 0 |         |
|                {3} | 0 1 0 0 0 0 0 0 0 |         |
|                {3} | 0 0 1 0 0 0 0 0 0 |         |
|                {3} | 0 0 0 1 0 0 0 0 0 |         |
|                {3} | 0 0 0 0 1 0 0 0 0 |         |
|                {3} | 0 0 0 0 0 1 0 0 0 |         |
|                {3} | 0 0 0 0 0 0 1 0 0 |         |
|                {3} | 0 0 0 0 0 0 0 1 0 |         |
|                                                  |
|           3                     3                |
|      4 : S  <----------------- S  : 4            |
|                {4} | 1 0 0 |                     |
|                {4} | 0 1 0 |                     |
|                {4} | 0 0 1 |                     |
|                                                  |
|o11 : ComplexMap                                  |
+--------------------------------------------------+
|i12 : assert(isWellDefined g and isWellDefined h) |
+--------------------------------------------------+
|i13 : assert(isShortExactSequence(h,g))           |
+--------------------------------------------------+

The most important application of mapping cones is to identify
quasi-isomorphisms: $f$ is a quasi-isomorphism if and only if the mapping cone
is acyclic.

+----------------------------------------------------+
|i14 : aug = augmentationMap C                       |
|                                                    |
|                                         1          |
|o14 = 0 : cokernel | x y z | <--------- S  : 0      |
|                                | 1 |               |
|                                                    |
|o14 : ComplexMap                                    |
+----------------------------------------------------+
|i15 : assert isWellDefined aug                      |
+----------------------------------------------------+
|i16 : cone aug                                      |
|                                                    |
|                              1      3      3      1|
|o16 = cokernel | x y z | <-- S  <-- S  <-- S  <-- S |
|                                                    |
|      0                      1      2      3      4 |
|                                                    |
|o16 : Complex                                       |
+----------------------------------------------------+
|i17 : assert(0 == prune HH cone aug)                |
+----------------------------------------------------+
|i18 : assert isQuasiIsomorphism aug                 |
+----------------------------------------------------+

Mapping cones can also be used to construct free resolutions of subschemes
linked via a complete intersection to a arithmetically Cohen-Macaulay
subscheme; see Peskine-Szpiro, Liaison des variétés algébriques I, Invent.
math. 26 (1974) 271-302.

Here, we consider a random complete intersection of 2 cubics contained in the
ideal of the twisted cubic curve, and we compute a free resolution of the
linked curve of degree 6.

+-----------------------------------------------------------------------------+
|i19 : S = ZZ/32003[a..d]                                                     |
|                                                                             |
|o19 = S                                                                      |
|                                                                             |
|o19 : PolynomialRing                                                         |
+-----------------------------------------------------------------------------+
|i20 : I = monomialCurveIdeal(S, {1,2,3})                                     |
|                                                                             |
|              2                    2                                         |
|o20 = ideal (c  - b*d, b*c - a*d, b  - a*c)                                  |
|                                                                             |
|o20 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i21 : K = ideal((gens I) * random(source gens I, S^{-3,-3}))                 |
|                                                                             |
|                    2         3        2                      2            2 |
|o21 = ideal (8444a*b  - 10480b  - 8444a c + 14263a*b*c + 5052b c - 10252a*c  |
|      -----------------------------------------------------------------------|
|                2        3        2                      2                   |
|      + 12946b*c  - 5570c  - 3783a d + 5200a*b*d - 11840b d - 1106a*c*d -    |
|      -----------------------------------------------------------------------|
|                       2            2          2         2        3        2 |
|      9774b*c*d + 3187c d + 15344a*d  - 3187b*d , 8231a*b  + 5864b  - 8231a c|
|      -----------------------------------------------------------------------|
|                         2            2          2        3         2        |
|      + 6501a*b*c - 8482b c - 13277a*c  - 6827b*c  + 5071c  - 12365a d -     |
|      -----------------------------------------------------------------------|
|                        2                                 2            2     |
|      10244a*b*d + 7606b d - 779a*c*d + 14982b*c*d - 6203c d + 11950a*d  +   |
|      -----------------------------------------------------------------------|
|             2                                                               |
|      6203b*d )                                                              |
|                                                                             |
|o21 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i22 : C = freeResolution(S^1/I)                                              |
|                                                                             |
|       1      3      2                                                       |
|o22 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o22 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i23 : B = freeResolution(S^1/K)                                              |
|                                                                             |
|       1      2      1                                                       |
|o23 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o23 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i24 : f = dual extend(C,B,id_(S^1))                                          |
|                                                                             |
|            1                                                                |
|o24 = -2 : S  <--------------------------------------------------------------|
|                 {-6} | a2b+13164ab2+7073b3+14275a2c+12412abc+5971b2c+5936ac2|
|                                                                             |
|            2                                                                |
|      -1 : S  <--------------------------------------------------------------|
|                 {-3} | a-9704b-6703d -815a-6222b-2797d  -3046a+6364b-4113c+5|
|                 {-3} | b+6234d       12692a+4634b+3570d 9317a+14985b+4650c+3|
|                                                                             |
|           1             1                                                   |
|      0 : S  <--------- S  : 0                                               |
|                | 1 |                                                        |
|                                                                             |
|o24 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|-1626bc2-13990a2d+2551abd+4239b2d+713acd+13423bcd-14082c2d-8823ad2-4362bd2-14|
|                                                                             |
|          3                                                                  |
|-------- S  : -1                                                             |
|637d |                                                                       |
|653d |                                                                       |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|372cd2-5192d3 a3-4564a2b-12518ab2+5971b3-13990a2c+13569abc-9576b2c-1274ac2-45|
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|45bc2-5082a2d+14176abd-14035b2d-8823acd+9663bcd-4810c2d+3896ad2-9562bd2-5192c|
|-----------------------------------------------------------------------------|
|        2                                                                    |
|------ S  : -2                                                               |
|d2 |                                                                         |
+-----------------------------------------------------------------------------+
|i25 : Cf = (cone f)[-2]                                                      |
|                                                                             |
|       1      4      4      1                                                |
|o25 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o25 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i26 : prune HH Cf                                                            |
|                                                                             |
|o26 = cokernel {-6} | b3+12691abc+4634b2c+9317ac2+14985bc2+4650c3-12692a2d-  |
|                                                                             |
|      0                                                                      |
|                                                                             |
|o26 : Complex                                                                |
|-----------------------------------------------------------------------------|
|13951abd-8751b2d-6234acd-1080bcd+3653c2d-3570ad2-3653bd2                     |
|-----------------------------------------------------------------------------|
|ab2-a2c+14809abc-2101b2c+647ac2-828bc2-4743c3-14809a2d+1454abd+3191b2d-      |
|-----------------------------------------------------------------------------|
|2363acd-14023bcd-4975c2d-13237ad2+4975bd2                                    |
|-----------------------------------------------------------------------------|
|a2b-4564a2c+1981abc+7733b2c-3338ac2-9826bc2+8633c3+3514a2d+10063abd-12128b2d-|
|-----------------------------------------------------------------------------|
|6723acd+9014bcd-12568c2d-13047ad2-5876bd2-14372cd2-5192d3                    |
|-----------------------------------------------------------------------------|
|a3+9352a2c-11170abc+3656b2c-10684ac2-5185bc2+11464c3+14456a2d+6480abd-4521b2d|
|-----------------------------------------------------------------------------|
|-7255acd+6319bcd-1015c2d-3792ad2+8120bd2+7150cd2-14068d3 |                   |
+-----------------------------------------------------------------------------+
|i27 : Cf' = minimize Cf                                                      |
|                                                                             |
|       1      4      3                                                       |
|o27 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o27 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i28 : J = ideal dd^Cf'_1                                                     |
|                                                                             |
|              2            2        3         2                      2       |
|o28 = ideal (a b + 13164a*b  + 7073b  + 14275a c + 12412a*b*c + 5971b c +    |
|      -----------------------------------------------------------------------|
|             2          2         2                     2                    |
|      5936a*c  - 1626b*c  - 13990a d + 2551a*b*d + 4239b d + 713a*c*d +      |
|      -----------------------------------------------------------------------|
|                         2           2          2           2        3   3   |
|      13423b*c*d - 14082c d - 8823a*d  - 4362b*d  - 14372c*d  - 5192d , a  - |
|      -----------------------------------------------------------------------|
|           2            2        3         2                      2          |
|      4564a b - 12518a*b  + 5971b  - 13990a c + 13569a*b*c - 9576b c -       |
|      -----------------------------------------------------------------------|
|             2          2        2                       2                   |
|      1274a*c  - 4545b*c  - 5082a d + 14176a*b*d - 14035b d - 8823a*c*d +    |
|      -----------------------------------------------------------------------|
|                       2           2          2          2         3         |
|      9663b*c*d - 4810c d + 3896a*d  - 9562b*d  - 5192c*d , - 9554b  +       |
|      -----------------------------------------------------------------------|
|                        2            2           2        3    2             |
|      9553a*b*c - 13087b c - 14275a*c  + 14732b*c  - 5936c  + a d - 4641a*b*d|
|      -----------------------------------------------------------------------|
|              2                                   2           2           2  |
|      + 15218b d + 2053a*c*d + 13354b*c*d + 14511c d - 7418a*d  - 14511b*d , |
|      -----------------------------------------------------------------------|
|             2       3        2                       2            2         |
|      9554a*b  + 675b  - 9554a c - 10456a*b*c - 15417b c - 10757a*c  -       |
|      -----------------------------------------------------------------------|
|             2        3        2                     2                       |
|      4044b*c  + 4082c  + 9781a d - 5829a*b*d + 1585b d + 2459a*c*d -        |
|      -----------------------------------------------------------------------|
|                       2         2          2                                |
|      4115b*c*d - 5151c d + 33a*d  + 5151b*d )                               |
|                                                                             |
|o28 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i29 : freeResolution J                                                       |
|                                                                             |
|       1      4      3                                                       |
|o29 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o29 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i30 : assert(degree J == 6)                                                  |
+-----------------------------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * cylinder(ComplexMap) -- make the mapping cylinder of a
    morphism of chain complexes
  * augmentationMap(Complex) -- map from a free
    resolution to a module regarded as a complex
  * extend(Complex,Complex,Matrix)
    -- extend a map of
    modules to a map of chain complexes
  * freeResolution(Module) -- compute a free resolution
    of a module or ideal
  * canonicalMap -- gets the natural map arising from
    various constructions
  * isQuasiIsomorphism -- whether a
    map of complexes is a quasi-isomorphism
  * isShortExactSequence -- whether a
    chain complex is a short exact sequence

Ways to use this method:
========================

  * cone(ComplexMap) -- make the mapping cone of a
    morphism of chain complexes

connectingExtMap(Module,Matrix,Matrix) -- makes the connecting maps in Ext
**************************************************************************

Synopsis
========

  * Function: connectingExtMap,
  * Usage:
        connectingExtMap(M, g, f)
        connectingExtMap(g, f, M)
  * Inputs:
      * M, a module (Macaulay2Doc), over a ring $S$
      * f, a matrix (Macaulay2Doc), over a ring $S$ defining an
        injective map $f \colon A \to B$
      * g, a matrix (Macaulay2Doc), over a ring $S$ defining a
        surjective map $g \colon B \to C$ such that the image of $f$ equals the
        kernel of $g$
  * Optional inputs (Macaulay2Doc),:
      * Concentration => a sequence (Macaulay2Doc), default
        value null, not yet implemented
  * Outputs:
      * a map of complexes,

Description
===========

Since Ext is a bifunctor, there are two different connecting maps. The first
comes from applying the covariant functor $\operatorname{Hom}_S(M, -)$ to a
short exact sequence of modules.  The second comes from applying the
contravariant functor $\operatorname{Hom}_S(-, M)$ to a short exact sequence of
modules. More explicitly, given the short exact sequence

$\phantom{WWWW} 0 \leftarrow C \xleftarrow{g} B  \xleftarrow{f} A \leftarrow 0,
$

the $(-i)$-th connecting homomorphism is, in the first case, a map
$\operatorname{Ext}_S^i(M, C) \to \operatorname{Ext}_S^{i+1}(M, A)$ and, in the
second case, a map $\operatorname{Ext}_S^i(A, M) \to
\operatorname{Ext}_S^{i+1}(C, M)$.  Observe that the connecting homomorphism is
indexed homologically, whereas Ext modules are indexed cohomologically,
explaining the different signs for the index $i$.

As a first example, applying the functor $\operatorname{Hom}(S/I, -)$ to a
short exact sequence of modules

$\phantom{WWWW} 0 \leftarrow S/h \leftarrow S \xleftarrow{h} S(- \deg h)
\leftarrow 0 $

gives rise to the long exact sequence in Ext modules having the form

$\phantom{WWWW} \dotsb \leftarrow \operatorname{Ext}^{i+1}(S/I, S(-\deg h))
\xleftarrow{\delta_{-i}} \operatorname{Ext}^i(S/I, S/h) \leftarrow
\operatorname{Ext}^i(S/I, S) \leftarrow \operatorname{Ext}^i(S/I, S(-\deg h))
\leftarrow \dotsb. $

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..d, Degrees=>{2:{1,0},2:{0,1}}];                           |
+-----------------------------------------------------------------------------+
|i2 : h = a*c^2 + a*c*d + b*d^2;                                              |
+-----------------------------------------------------------------------------+
|i3 : I = (ideal(a,b) * ideal(c,d))^[2]                                       |
|                                                                             |
|             2 2   2 2   2 2   2 2                                           |
|o3 = ideal (a c , a d , b c , b d )                                          |
|                                                                             |
|o3 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i4 : g = map(S^1/h, S^1, 1)                                                  |
|                                                                             |
|o4 = | 1 |                                                                   |
|                                                                             |
|o4 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i5 : f = map(S^1, S^{-degree h}, {{h}})                                      |
|                                                                             |
|o5 = | ac2+acd+bd2 |                                                         |
|                                                                             |
|             1       1                                                       |
|o5 : Matrix S  <--- S                                                        |
+-----------------------------------------------------------------------------+
|i6 : assert isShortExactSequence(g,f)                                        |
+-----------------------------------------------------------------------------+
|i7 : delta = connectingExtMap(S^1/I, g, f)                                   |
|                                                                             |
|o7 = -2 : cokernel {-3, -2} | d2 -c2 -b2 a2                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|     -1 : subquotient ({-3, 0}  | c2 b2 0                                    |
|                       {-3, 0}  | d2 0  b2                                   |
|                       {-1, -2} | 0  d2 -c2                                  |
|                       {-1, -2} | 0  0  0                                    |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|| <--------------------------------------                                    |
|     {-3, -2} | 0 -d c 0 0 0 0 -a 0 0 |                                      |
|                                                                             |
|                                                                             |
|                                                                             |
|a2  0  0  |, {-3, 0}  | -b2 a2  0   0  |)                                    |
|0   a2 0  |  {-3, 0}  | 0   0   -b2 a2 |                                     |
|0   0  a2 |  {-1, -2} | -d2 0   c2  0  |                                     |
|-d2 c2 b2 |  {-1, -2} | 0   -d2 0   c2 |                                     |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|subquotient ({-4, -2} | c2 ac+bd -bc   b2 0   a2  0  ab    0  0           |, |
|             {-4, -2} | d2 -ad   ac+ad 0  b2  0   a2 0     0  0           |  |
|             {-2, -4} | 0  0     0     d2 -c2 0   0  0     a2 ac2+acd+bd2 |  |
|             {-2, -4} | 0  0     0     0  0   -d2 c2 c2+cd b2 0           |  |
|                                                                             |
|<----------------------------------------------- subquotient ({-2, -2} | ac2+|
|   {-3, 2} | 0 0 0 0 0 0 0  -ab -ac2-acd+bd2 |                {-2, -2} | 0   |
|   {-1, 0} | 0 0 0 0 0 0 0  0   0            |                {-2, -2} | 0   |
|   {-1, 0} | 0 0 0 0 0 0 0  0   0            |                {-2, -2} | 0   |
|   {-1, 0} | 0 0 0 0 0 0 0  0   0            |                               |
|   {-1, 0} | 0 0 0 0 0 0 0  0   0            |                               |
|   {1, -2} | 0 0 0 0 0 d -c 0   0            |                               |
|-----------------------------------------------------------------------------|
|{-4, -2} | -b2 a2  0   0  ac2+acd+bd2 0           0           0              |
|{-4, -2} | 0   0   -b2 a2 0           ac2+acd+bd2 0           0              |
|{-2, -4} | -d2 0   c2  0  0           0           ac2+acd+bd2 0              |
|{-2, -4} | 0   -d2 0   c2 0           0           0           ac2+acd+bd2    |
|                                                                             |
|acd+bd2 0           0           0           -a2cd-abd2 a3c+a2bd -a2bc        |
|        ac2+acd+bd2 0           0           b2c2       ab2c+b3d -b3c         |
|        0           ac2+acd+bd2 0           a2d2       -a3d     a3c+a3d      |
|        0           0           ac2+acd+bd2 b2d2       -ab2d    ab2c+ab2d    |
|-----------------------------------------------------------------------------|
||) : -2                                                                      |
||                                                                            |
||                                                                            |
||                                                                            |
|                                                                             |
|acd3+bd4   c2d4            |, {-2, -2} | -a2cd-abd2 ac2+acd+bd2 0            |
|bc4+bc3d   c6+2c5d+c4d2    |  {-2, -2} | b2c2       0           ac2+acd+bd2  |
|-ad4       d6              |  {-2, -2} | a2d2       0           0            |
|bc2d2+bcd3 c4d2+2c3d3+c2d4 |  {-2, -2} | b2d2       0           0            |
|-----------------------------------------------------------------------------|
|0           0           |) : -1                                              |
|0           0           |                                                    |
|ac2+acd+bd2 0           |                                                    |
|0           ac2+acd+bd2 |                                                    |
+-----------------------------------------------------------------------------+
|i8 : assert isWellDefined delta                                              |
+-----------------------------------------------------------------------------+
|i9 : assert(degree delta == 0)                                               |
+-----------------------------------------------------------------------------+
|i10 : assert(source delta_(-1) == Ext^1(comodule I, S^1/h))                  |
+-----------------------------------------------------------------------------+
|i11 : assert(target delta_(-1) == Ext^2(comodule I, S^{{-1,-2}}))            |
+-----------------------------------------------------------------------------+

As a second example, applying the functor $\operatorname{Hom}(-, S)$ to the
short exact sequence of modules

$\phantom{WWWW} 0 \leftarrow S/(I+J) \leftarrow S/I \oplus S/J  \leftarrow S/I
\cap J \leftarrow 0 $

gives rise to the long exact sequence of Ext modules having the form

$\phantom{WWWW} \dotsb \leftarrow \operatorname{Ext}^{i+1}(S/(I+J), S)
\xleftarrow{\delta_{-i}} \operatorname{Ext}^i(S/I \cap J, S) \leftarrow
\operatorname{Ext}^i(S/I \oplus S/J, S) \leftarrow
\operatorname{Ext}^i(S/(I+J), S) \leftarrow \dotsb. $

+-----------------------------------------------------------------------------+
|i12 : S = ZZ/101[a..d];                                                      |
+-----------------------------------------------------------------------------+
|i13 : I = ideal(c^3-b*d^2, b*c-a*d)                                          |
|                                                                             |
|              3      2                                                       |
|o13 = ideal (c  - b*d , b*c - a*d)                                           |
|                                                                             |
|o13 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i14 : J = ideal(a*c^2-b^2*d, b^3-a^2*c)                                      |
|                                                                             |
|                2    2    3    2                                             |
|o14 = ideal (a*c  - b d, b  - a c)                                           |
|                                                                             |
|o14 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i15 : g = map(S^1/(I+J), S^1/I ++ S^1/J, {{1,1}})                            |
|                                                                             |
|o15 = | 1 1 |                                                                |
|                                                                             |
|o15 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i16 : f = map(S^1/I ++ S^1/J, S^1/intersect(I,J), {{1},{-1}})                |
|                                                                             |
|o16 = | 1  |                                                                 |
|      | -1 |                                                                 |
|                                                                             |
|o16 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i17 : assert isShortExactSequence(g,f)                                       |
+-----------------------------------------------------------------------------+
|i18 : delta = connectingExtMap(g, f, S^1)                                    |
|                                                                             |
|o18 = -2 : cokernel {-5} | d -c -b a | <------------------ cokernel {-5} |   |
|                                          {-5} | 1 0 0 |            {-5} |   |
|                                                                    {-6} |   |
|                                                                             |
|o18 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|d   -c b  -a | : -2                                                          |
|0   0  -d c  |                                                               |
|-ac b2 0  0  |                                                               |
+-----------------------------------------------------------------------------+
|i19 : assert isWellDefined delta                                             |
+-----------------------------------------------------------------------------+
|i20 : assert(source delta_-2 == Ext^2(comodule intersect(I,J), S))           |
+-----------------------------------------------------------------------------+
|i21 : assert(target delta_-2 == Ext^3(comodule (I+J), S))                    |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Ext -- information about functorial
    properties
  * connectingMap, --
    construct the connecting homomorphism on homology
  * isShortExactSequence -- whether a
    chain complex is a short exact sequence
  * longExactSequence, --
    make the long exact sequence in homology
  * Ext (Macaulay2Doc) -- compute an Ext module
  * Working with Tor -- information about functorial
    properties

Ways to use this method:
========================

  * "connectingExtMap(Matrix,Matrix,Module)"
  * connectingExtMap(Module,Matrix,Matrix)
    -- makes the connecting
    maps in Ext

connectingMap(ComplexMap,ComplexMap) -- construct the connecting homomorphism on homology
*****************************************************************************************

Synopsis
========

  * Function: connectingMap,
  * Usage:
        connectingMap(g, f)
  * Inputs:
      * f, a map of complexes, an injective morphism $f
        \colon A \to B$
      * g, a map of complexes, a surjective morphism $g
        \colon B \to C$ whose kernel is the same as the image of $f$
  * Optional inputs (Macaulay2Doc),:
      * Concentration => a sequence (Macaulay2Doc), default
        value null, not yet implemented
  * Outputs:
      * h, a map of complexes, a complex morphism whose
        source is the homology of $C$ and whose target is the homology of $A$,
        shifted by $-1$

Description
===========

Given a short exact sequence of chain complexes

$\phantom{WWWW} 0 \leftarrow C \xleftarrow{g} B \xleftarrow{f} A \leftarrow 0,
$

this function returns the unique morphism $h \colon H(C) \to H(A)[-1]$ of
complexes that naturally fits into the long exact sequence

$\phantom{WWWW} \dotsb \leftarrow H(C)[-1] \xleftarrow{H(g)[-1]} H(B)[-1]
\xleftarrow{H(f)[-1]} H(A)[-1] \xleftarrow{h} H(C) \xleftarrow{H(g)} H(B)
\xleftarrow{H(f)} H(A) \leftarrow \dotsb. $

$\phantom{WWWW}$

As a first example, consider a free resolution $F$ of $S/I$. Applying the Hom
functor $\operatorname{Hom}(F, -)$ to a short exact sequence of modules

$\phantom{WWWW} 0 \leftarrow S/h \leftarrow S \xleftarrow{h} S(- \deg h)
\leftarrow 0 $

gives rise to a short exact sequence of complexes.  The corresponding long
exact sequence in homology has the form

$\phantom{WWWW} \dotsb \leftarrow \operatorname{Ext}^{d+1}(S/I, S(-\deg h))
\xleftarrow{\delta} \operatorname{Ext}^d(S/I, S/h) \leftarrow
\operatorname{Ext}^d(S/I, S) \leftarrow \operatorname{Ext}^d(S/I, S(-\deg h))
\leftarrow \dotsb. $

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..d, Degrees=>{2:{1,0},2:{0,1}}];                           |
+-----------------------------------------------------------------------------+
|i2 : h = a*c^2 + a*c*d + b*d^2;                                              |
+-----------------------------------------------------------------------------+
|i3 : I = (ideal(a,b) * ideal(c,d))^[2]                                       |
|                                                                             |
|             2 2   2 2   2 2   2 2                                           |
|o3 = ideal (a c , a d , b c , b d )                                          |
|                                                                             |
|o3 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i4 : F = freeResolution comodule I;                                          |
+-----------------------------------------------------------------------------+
|i5 : g = Hom(F, map(S^1/h, S^1, 1))                                          |
|                                                                             |
|                                                                 1           |
|o5 = -3 : cokernel {-4, -4} | ac2+acd+bd2 | <------------------ S  : -3      |
|                                               {-4, -4} | 1 |                |
|                                                                             |
|                                                                             |
|     -2 : cokernel {-4, -2} | ac2+acd+bd2 0           0           0          |
|                   {-4, -2} | 0           ac2+acd+bd2 0           0          |
|                   {-2, -4} | 0           0           ac2+acd+bd2 0          |
|                   {-2, -4} | 0           0           0           ac2+acd+bd2|
|                                                                             |
|                                                                             |
|                                                                             |
|     -1 : cokernel {-2, -2} | ac2+acd+bd2 0           0           0          |
|                   {-2, -2} | 0           ac2+acd+bd2 0           0          |
|                   {-2, -2} | 0           0           ac2+acd+bd2 0          |
|                   {-2, -2} | 0           0           0           ac2+acd+bd2|
|                                                                             |
|                                                                             |
|                                              1                              |
|     0 : cokernel | ac2+acd+bd2 | <--------- S  : 0                          |
|                                     | 1 |                                   |
|                                                                             |
|o5 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                             4                                               |
|| <------------------------ S  : -2                                          |
||    {-4, -2} | 1 0 0 0 |                                                    |
||    {-4, -2} | 0 1 0 0 |                                                    |
||    {-2, -4} | 0 0 1 0 |                                                    |
|     {-2, -4} | 0 0 0 1 |                                                    |
|                                                                             |
|                             4                                               |
|| <------------------------ S  : -1                                          |
||    {-2, -2} | 1 0 0 0 |                                                    |
||    {-2, -2} | 0 1 0 0 |                                                    |
||    {-2, -2} | 0 0 1 0 |                                                    |
|     {-2, -2} | 0 0 0 1 |                                                    |
+-----------------------------------------------------------------------------+
|i6 : f = Hom(F, map(S^1, S^{-degree h}, {{h}}))                              |
|                                                                             |
|           1                                1                                |
|o6 = -3 : S  <---------------------------- S  : -3                           |
|                {-4, -4} | ac2+acd+bd2 |                                     |
|                                                                             |
|           4                                                                 |
|     -2 : S  <---------------------------------------------------------------|
|                {-4, -2} | ac2+acd+bd2 0           0           0           | |
|                {-4, -2} | 0           ac2+acd+bd2 0           0           | |
|                {-2, -4} | 0           0           ac2+acd+bd2 0           | |
|                {-2, -4} | 0           0           0           ac2+acd+bd2 | |
|                                                                             |
|           4                                                                 |
|     -1 : S  <---------------------------------------------------------------|
|                {-2, -2} | ac2+acd+bd2 0           0           0           | |
|                {-2, -2} | 0           ac2+acd+bd2 0           0           | |
|                {-2, -2} | 0           0           ac2+acd+bd2 0           | |
|                {-2, -2} | 0           0           0           ac2+acd+bd2 | |
|                                                                             |
|          1                       1                                          |
|     0 : S  <------------------- S  : 0                                      |
|               | ac2+acd+bd2 |                                               |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|   4                                                                         |
|- S  : -2                                                                    |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|   4                                                                         |
|- S  : -1                                                                    |
+-----------------------------------------------------------------------------+
|i7 : assert isWellDefined g                                                  |
+-----------------------------------------------------------------------------+
|i8 : assert isWellDefined f                                                  |
+-----------------------------------------------------------------------------+
|i9 : assert isShortExactSequence(g, f)                                       |
+-----------------------------------------------------------------------------+
|i10 : delta = connectingMap(g, f)                                            |
|                                                                             |
|o10 = -2 : cokernel {-3, -2} | d2 -c2 -b2 a2                                 |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      -1 : subquotient ({-3, 0}  | c2 b2 0                                   |
|                        {-3, 0}  | d2 0  b2                                  |
|                        {-1, -2} | 0  d2 -c2                                 |
|                        {-1, -2} | 0  0  0                                   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o10 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|| <--------------------------------------                                    |
|     {-3, -2} | 0 -d c 0 0 0 0 -a 0 0 |                                      |
|                                                                             |
|                                                                             |
|                                                                             |
|a2  0  0  |, {-3, 0}  | -b2 a2  0   0  |)                                    |
|0   a2 0  |  {-3, 0}  | 0   0   -b2 a2 |                                     |
|0   0  a2 |  {-1, -2} | -d2 0   c2  0  |                                     |
|-d2 c2 b2 |  {-1, -2} | 0   -d2 0   c2 |                                     |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|subquotient ({-4, -2} | c2 ac+bd -bc   b2 0   a2  0  ab    0  0           |, |
|             {-4, -2} | d2 -ad   ac+ad 0  b2  0   a2 0     0  0           |  |
|             {-2, -4} | 0  0     0     d2 -c2 0   0  0     a2 ac2+acd+bd2 |  |
|             {-2, -4} | 0  0     0     0  0   -d2 c2 c2+cd b2 0           |  |
|                                                                             |
|<----------------------------------------------- subquotient ({-2, -2} | ac2+|
|   {-3, 2} | 0 0 0 0 0 0 0  -ab -ac2-acd+bd2 |                {-2, -2} | 0   |
|   {-1, 0} | 0 0 0 0 0 0 0  0   0            |                {-2, -2} | 0   |
|   {-1, 0} | 0 0 0 0 0 0 0  0   0            |                {-2, -2} | 0   |
|   {-1, 0} | 0 0 0 0 0 0 0  0   0            |                               |
|   {-1, 0} | 0 0 0 0 0 0 0  0   0            |                               |
|   {1, -2} | 0 0 0 0 0 d -c 0   0            |                               |
|-----------------------------------------------------------------------------|
|{-4, -2} | -b2 a2  0   0  ac2+acd+bd2 0           0           0              |
|{-4, -2} | 0   0   -b2 a2 0           ac2+acd+bd2 0           0              |
|{-2, -4} | -d2 0   c2  0  0           0           ac2+acd+bd2 0              |
|{-2, -4} | 0   -d2 0   c2 0           0           0           ac2+acd+bd2    |
|                                                                             |
|acd+bd2 0           0           0           -a2cd-abd2 a3c+a2bd -a2bc        |
|        ac2+acd+bd2 0           0           b2c2       ab2c+b3d -b3c         |
|        0           ac2+acd+bd2 0           a2d2       -a3d     a3c+a3d      |
|        0           0           ac2+acd+bd2 b2d2       -ab2d    ab2c+ab2d    |
|-----------------------------------------------------------------------------|
||) : -2                                                                      |
||                                                                            |
||                                                                            |
||                                                                            |
|                                                                             |
|acd3+bd4   c2d4            |, {-2, -2} | -a2cd-abd2 ac2+acd+bd2 0            |
|bc4+bc3d   c6+2c5d+c4d2    |  {-2, -2} | b2c2       0           ac2+acd+bd2  |
|-ad4       d6              |  {-2, -2} | a2d2       0           0            |
|bc2d2+bcd3 c4d2+2c3d3+c2d4 |  {-2, -2} | b2d2       0           0            |
|-----------------------------------------------------------------------------|
|0           0           |) : -1                                              |
|0           0           |                                                    |
|ac2+acd+bd2 0           |                                                    |
|0           ac2+acd+bd2 |                                                    |
+-----------------------------------------------------------------------------+
|i11 : assert isWellDefined delta                                             |
+-----------------------------------------------------------------------------+
|i12 : assert(degree delta == 0)                                              |
+-----------------------------------------------------------------------------+
|i13 : assert(source delta_(-1) == Ext^1(comodule I, S^1/h))                  |
+-----------------------------------------------------------------------------+
|i14 : assert(target delta_(-1) == Ext^2(comodule I, S^{{-1,-2}}))            |
+-----------------------------------------------------------------------------+
|i15 : L = longExactSequence(g,f)                                             |
|                                                                             |
|o15 = cokernel {-4, -4} | d2 -c2 -b2 a2 ac2+acd+bd2 | <-- cokernel {-4, -4} ||
|                                                                             |
|      -9                                                  -8                 |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o15 : Complex                                                                |
|-----------------------------------------------------------------------------|
|d2 -c2 -b2 a2 | <-- cokernel {-3, -2} | d2 -c2 -b2 a2 | <-- subquotient ({-4,|
|                                                                         {-4,|
|                    -7                                                   {-2,|
|                                                                         {-2,|
|                                                                             |
|                                                            -6               |
|-----------------------------------------------------------------------------|
|-2} | c2 ac+bd -bc   b2 0   a2  0  ab    0  0           |, {-4, -2} | -b2 a2 |
|-2} | d2 -ad   ac+ad 0  b2  0   a2 0     0  0           |  {-4, -2} | 0   0  |
|-4} | 0  0     0     d2 -c2 0   0  0     a2 ac2+acd+bd2 |  {-2, -4} | -d2 0  |
|-4} | 0  0     0     0  0   -d2 c2 c2+cd b2 0           |  {-2, -4} | 0   -d2|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|0   0  ac2+acd+bd2 0           0           0           |) <-- subquotient    |
|-b2 a2 0           ac2+acd+bd2 0           0           |                     |
|c2  0  0           0           ac2+acd+bd2 0           |                     |
|0   c2 0           0           0           ac2+acd+bd2 |                     |
|                                                                             |
|                                                              -5             |
|-----------------------------------------------------------------------------|
|({-4, -2} | c2 b2 0   a2  0  0  |, {-4, -2} | -b2 a2  0   0  |) <--          |
| {-4, -2} | d2 0  b2  0   a2 0  |  {-4, -2} | 0   0   -b2 a2 |               |
| {-2, -4} | 0  d2 -c2 0   0  a2 |  {-2, -4} | -d2 0   c2  0  |               |
| {-2, -4} | 0  0  0   -d2 c2 b2 |  {-2, -4} | 0   -d2 0   c2 |               |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|subquotient ({-3, 0}  | c2 b2 0   a2  0  0  |, {-3, 0}  | -b2 a2  0   0  |)  |
|             {-3, 0}  | d2 0  b2  0   a2 0  |  {-3, 0}  | 0   0   -b2 a2 |   |
|             {-1, -2} | 0  d2 -c2 0   0  a2 |  {-1, -2} | -d2 0   c2  0  |   |
|             {-1, -2} | 0  0  0   -d2 c2 b2 |  {-1, -2} | 0   -d2 0   c2 |   |
|                                                                             |
|-4                                                                           |
|-----------------------------------------------------------------------------|
|<-- subquotient ({-2, -2} | ac2+acd+bd2 0           0           0            |
|                 {-2, -2} | 0           ac2+acd+bd2 0           0            |
|                 {-2, -2} | 0           0           ac2+acd+bd2 0            |
|                 {-2, -2} | 0           0           0           ac2+acd+bd2  |
|                                                                             |
|    -3                                                                       |
|-----------------------------------------------------------------------------|
|-a2cd-abd2 a3c+a2bd -a2bc     acd3+bd4   c2d4            |, {-2, -2} |       |
|b2c2       ab2c+b3d -b3c      bc4+bc3d   c6+2c5d+c4d2    |  {-2, -2} |       |
|a2d2       -a3d     a3c+a3d   -ad4       d6              |  {-2, -2} |       |
|b2d2       -ab2d    ab2c+ab2d bc2d2+bcd3 c4d2+2c3d3+c2d4 |  {-2, -2} |       |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|-a2cd-abd2 ac2+acd+bd2 0           0           0           |) <-- subquotient|
|b2c2       0           ac2+acd+bd2 0           0           |                 |
|a2d2       0           0           ac2+acd+bd2 0           |                 |
|b2d2       0           0           0           ac2+acd+bd2 |                 |
|                                                                             |
|                                                                  -2         |
|-----------------------------------------------------------------------------|
|({-2, -2} | a2c2 |, {-2, -2} | a2c2 |) <-- subquotient ({-1, 0} | a2c2 |,    |
| {-2, -2} | b2c2 |  {-2, -2} | b2c2 |                   {-1, 0} | b2c2 |     |
| {-2, -2} | a2d2 |  {-2, -2} | a2d2 |                   {-1, 0} | a2d2 |     |
| {-2, -2} | b2d2 |  {-2, -2} | b2d2 |                   {-1, 0} | b2d2 |     |
|                                                                             |
|                                           -1                                |
|-----------------------------------------------------------------------------|
|{-1, 0} | a2c2 |) <-- subquotient (| ac2+acd+bd2 |, | ac2+acd+bd2 |) <--     |
|{-1, 0} | b2c2 |                                                             |
|{-1, 0} | a2d2 |      0                                                      |
|{-1, 0} | b2d2 |                                                             |
|-----------------------------------------------------------------------------|
|image 0 <-- image 0 <-- 0                                                    |
|                                                                             |
|1           2           3                                                    |
+-----------------------------------------------------------------------------+
|i16 : assert isWellDefined L                                                 |
+-----------------------------------------------------------------------------+
|i17 : assert(HH L == 0)                                                      |
+-----------------------------------------------------------------------------+
|i18 : assert(dd^L_-9 === delta_-3)                                           |
+-----------------------------------------------------------------------------+
|i19 : assert(dd^L_-8 === HH_-3 g)                                            |
+-----------------------------------------------------------------------------+
|i20 : assert(dd^L_-7 === HH_-3 f)                                            |
+-----------------------------------------------------------------------------+
|i21 : assert(dd^L_-6 === delta_-2)                                           |
+-----------------------------------------------------------------------------+
|i22 : assert(dd^L_-5 === HH_-2 g)                                            |
+-----------------------------------------------------------------------------+
|i23 : assert(dd^L_-4 === HH_-2 f)                                            |
+-----------------------------------------------------------------------------+
|i24 : assert(dd^L_-3 === delta_-1)                                           |
+-----------------------------------------------------------------------------+

Applying the Hom functor $\operatorname{Hom}(-, S)$ to the horseshoe resolution
of a short exact sequence of modules

$\phantom{WWWW} 0 \leftarrow S/(I+J) \leftarrow S/I \oplus S/J  \leftarrow S/I
\cap J \leftarrow 0 $

gives rise to a short exact sequence of complexes.  The corresponding long
exact sequence in homology has the form

$\phantom{WWWW} \dotsb \leftarrow \operatorname{Ext}^{d+1}(S/(I+J), S)
\xleftarrow{\delta} \operatorname{Ext}^d(S/I \cap J, S) \leftarrow
\operatorname{Ext}^d(S/I \oplus S/J, S) \leftarrow
\operatorname{Ext}^d(S/(I+J), S) \leftarrow \dotsb. $

+-----------------------------------------------------------------------------+
|i25 : S = ZZ/101[a..d];                                                      |
+-----------------------------------------------------------------------------+
|i26 : I = ideal(c^3-b*d^2, b*c-a*d)                                          |
|                                                                             |
|              3      2                                                       |
|o26 = ideal (c  - b*d , b*c - a*d)                                           |
|                                                                             |
|o26 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i27 : J = ideal(a*c^2-b^2*d, b^3-a^2*c)                                      |
|                                                                             |
|                2    2    3    2                                             |
|o27 = ideal (a*c  - b d, b  - a c)                                           |
|                                                                             |
|o27 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i28 : ses = complex{                                                         |
|          map(S^1/(I+J), S^1/I ++ S^1/J, {{1,1}}),                           |
|          map(S^1/I ++ S^1/J, S^1/intersect(I,J), {{1},{-1}})                |
|          }                                                                  |
|                                                                             |
|o28 = cokernel | c3-bd2 bc-ad ac2-b2d b3-a2c | <-- cokernel | c3-bd2 bc-ad   |
|                                                            | 0      0       |
|      0                                                                      |
|                                                   1                         |
|                                                                             |
|o28 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0       0      | <-- cokernel | ac2d-b2d2 ac3-b2cd abc2-a2cd b3c-ab2d |      |
|ac2-b2d b3-a2c |                                                             |
|                     2                                                       |
+-----------------------------------------------------------------------------+
|i29 : assert isWellDefined ses                                               |
+-----------------------------------------------------------------------------+
|i30 : assert(HH ses == 0)                                                    |
+-----------------------------------------------------------------------------+
|i31 : (g,f) = horseshoeResolution ses                                        |
|                                                                             |
|            1               2                           2                    |
|o31 = (0 : S  <----------- S  : 0                , 0 : S                     |
|                 | 0 1 |                                                     |
|                                                                             |
|            4                               8                                |
|       1 : S  <--------------------------- S  : 1       8                    |
|                 {2} | 0 0 0 0 1 0 0 0 |           1 : S                     |
|                 {3} | 0 0 0 0 0 1 0 0 |                                     |
|                 {3} | 0 0 0 0 0 0 1 0 |                                     |
|                 {3} | 0 0 0 0 0 0 0 1 |                                     |
|                                                                             |
|            4                             7                                  |
|       2 : S  <------------------------- S  : 2                              |
|                 {4} | 0 0 0 1 0 0 0 |                                       |
|                 {4} | 0 0 0 0 1 0 0 |                                       |
|                 {4} | 0 0 0 0 0 1 0 |                                       |
|                 {4} | 0 0 0 0 0 0 1 |                  7                    |
|                                                   2 : S                     |
|            1                 1                                              |
|       3 : S  <------------- S  : 3                                          |
|                 {5} | 1 |                                                   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      -----------------------------------------------------------------------|
|                  1                                                          |
|      <--------- S  : 0          )                                           |
|         | 1 |                                                               |
|         | 0 |                                                               |
|                                                                             |
|                            4                                                |
|      <------------------- S  : 1                                            |
|         {4} | 1 0 0 0 |                                                     |
|         {4} | 0 1 0 0 |                                                     |
|         {4} | 0 0 1 0 |                                                     |
|         {4} | 0 0 0 1 |                                                     |
|         {2} | 0 0 0 0 |                                                     |
|         {3} | 0 0 0 0 |                                                     |
|         {3} | 0 0 0 0 |                                                     |
|         {3} | 0 0 0 0 |                                                     |
|                                                                             |
|                          3                                                  |
|      <----------------- S  : 2                                              |
|         {5} | 1 0 0 |                                                       |
|         {5} | 0 1 0 |                                                       |
|         {6} | 0 0 1 |                                                       |
|         {4} | 0 0 0 |                                                       |
|         {4} | 0 0 0 |                                                       |
|         {4} | 0 0 0 |                                                       |
|         {4} | 0 0 0 |                                                       |
|                                                                             |
|o31 : Sequence                                                               |
+-----------------------------------------------------------------------------+
|i32 : assert isShortExactSequence(g,f)                                       |
+-----------------------------------------------------------------------------+
|i33 : (Hf, Hg) = (Hom(f, S), Hom(g, S));                                     |
+-----------------------------------------------------------------------------+
|i34 : assert isShortExactSequence(Hf, Hg)                                    |
+-----------------------------------------------------------------------------+
|i35 : delta = connectingMap(Hf, Hg)                                          |
|                                                                             |
|o35 = -2 : cokernel {-5} | d -c -b a | <------------------ cokernel {-5} |   |
|                                          {-5} | 1 0 0 |            {-5} |   |
|                                                                    {-6} |   |
|                                                                             |
|o35 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|d   -c b  -a | : -2                                                          |
|0   0  -d c  |                                                               |
|-ac b2 0  0  |                                                               |
+-----------------------------------------------------------------------------+
|i36 : assert isWellDefined delta                                             |
+-----------------------------------------------------------------------------+
|i37 : assert isComplexMorphism delta                                         |
+-----------------------------------------------------------------------------+
|i38 : assert(source delta_-2 == Ext^2(comodule intersect(I,J), S))           |
+-----------------------------------------------------------------------------+
|i39 : assert(target delta_-2 == Ext^3(comodule (I+J), S))                    |
+-----------------------------------------------------------------------------+
|i40 : L = longExactSequence(Hf, Hg)                                          |
|                                                                             |
|o40 = 0  <-- cokernel {-5} | -1 0 0 d -c -b a | <-- cokernel {-5} | d -c -b a|
|                                                                             |
|      -6     -5                                     -4                       |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o40 : Complex                                                                |
|-----------------------------------------------------------------------------|
|| <-- cokernel {-5} | d   -c b  -a | <-- subquotient ({-5} | 0 0 d c  b  a |,|
|               {-5} | 0   0  -d c  |                  {-5} | 0 1 0 0  0  0 | |
|               {-6} | -ac b2 0  0  |                  {-6} | 1 0 0 0  0  0 | |
|                                                      {-4} | 0 0 1 0  0  0 | |
|      -3                                              {-4} | 0 0 0 -1 0  0 | |
|                                                      {-4} | 0 0 0 0  -1 0 | |
|                                                      {-4} | 0 0 0 0  0  1 | |
|                                                                             |
|                                         -2                                  |
|                                                                             |
|-----------------------------------------------------------------------------|
|{-5} | d   -c b  -a 0   0 0  0 |) <-- subquotient ({-4} | c b 0  a  0 0 |,   |
|{-5} | 0   0  -d c  0   0 0  0 |                   {-4} | d 0 b  0  a 0 |    |
|{-6} | -ac b2 0  0  0   0 0  0 |                   {-4} | 0 d -c 0  0 a |    |
|{-4} | 1   0  0  0  -b2 c a  0 |                   {-4} | 0 0 0  -d c b |    |
|{-4} | 0   1  0  0  -ac d b  0 |                                             |
|{-4} | 0   0  -1 0  -bd 0 -c a |      -1                                     |
|{-4} | 0   0  0  -1 -c2 0 -d b |                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|{-4} | -b2 c a  0 |) <-- subquotient ({-4} | b3c-ab2d  |, {-4} | b3c-ab2d  |)|
|{-4} | -ac d b  0 |                   {-4} | abc2-a2cd |  {-4} | abc2-a2cd | |
|{-4} | -bd 0 -c a |                   {-4} | ac3-b2cd  |  {-4} | ac3-b2cd  | |
|{-4} | -c2 0 -d b |                   {-4} | ac2d-b2d2 |  {-4} | ac2d-b2d2 | |
|                                                                             |
|                         0                                                   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|<-- subquotient ({-4} | b3c-ab2d  0       |, {-4} | b3c-ab2d  0       |) <-- |
|                 {-4} | abc2-a2cd 0       |  {-4} | abc2-a2cd 0       |      |
|                 {-4} | ac3-b2cd  0       |  {-4} | ac3-b2cd  0       |      |
|                 {-4} | ac2d-b2d2 0       |  {-4} | ac2d-b2d2 0       |      |
|                 {-2} | bc-ad     bc-ad   |  {-2} | 0         bc-ad   |      |
|                 {-3} | 0         b3-a2c  |  {-3} | -b3+a2c   b3-a2c  |      |
|                 {-3} | 0         ac2-b2d |  {-3} | -ac2+b2d  ac2-b2d |      |
|                 {-3} | c3-bd2    c3-bd2  |  {-3} | 0         c3-bd2  |      |
|                                                                             |
|    1                                                                        |
|-----------------------------------------------------------------------------|
|subquotient ({-2} | bc-ad   |, {-2} | bc-ad   |) <-- image 0 <-- image 0 <-- |
|             {-3} | b3-a2c  |  {-3} | b3-a2c  |                              |
|             {-3} | ac2-b2d |  {-3} | ac2-b2d |      3           4           |
|             {-3} | c3-bd2  |  {-3} | c3-bd2  |                              |
|                                                                             |
|2                                                                            |
|-----------------------------------------------------------------------------|
|image 0 <-- 0                                                                |
|                                                                             |
|5           6                                                                |
+-----------------------------------------------------------------------------+
|i41 : assert isWellDefined L                                                 |
+-----------------------------------------------------------------------------+
|i42 : assert(HH L == 0)                                                      |
+-----------------------------------------------------------------------------+
|i43 : assert(dd^L_-6 === delta_-3)                                           |
+-----------------------------------------------------------------------------+
|i44 : assert(dd^L_-5 === HH_-3 Hf)                                           |
+-----------------------------------------------------------------------------+
|i45 : assert(dd^L_-4 === HH_-3 Hg)                                           |
+-----------------------------------------------------------------------------+
|i46 : assert(dd^L_-3 === delta_-2)                                           |
+-----------------------------------------------------------------------------+
|i47 : assert(dd^L_-2 === HH_-2 Hf)                                           |
+-----------------------------------------------------------------------------+
|i48 : assert(dd^L_-1 === HH_-2 Hg)                                           |
+-----------------------------------------------------------------------------+
|i49 : assert(dd^L_0 === delta_-1)                                            |
+-----------------------------------------------------------------------------+

See also
========

  * Towards computing in the derived category
  * longExactSequence(ComplexMap,ComplexMap)
    -- make the long exact
    sequence in homology

Ways to use this method:
========================

  * connectingMap(ComplexMap,ComplexMap)
    -- construct the connecting
    homomorphism on homology

connectingTorMap(Module,Matrix,Matrix) -- makes the connecting maps in Tor
**************************************************************************

Synopsis
========

  * Function: connectingTorMap,
  * Usage:
        connectingTorMap(M, g, f)
        connectingTorMap(g, f, M)
  * Inputs:
      * M, a module (Macaulay2Doc), over a ring $S$
      * f, a matrix (Macaulay2Doc), over a ring $S$ defining an
        injective map $f \colon A \to B$
      * g, a matrix (Macaulay2Doc), over a ring $S$ defining a
        surjective map $g \colon B \to C$ such that the image of $f$ equals the
        kernel of $g$
  * Optional inputs (Macaulay2Doc),:
      * Concentration => a sequence (Macaulay2Doc), default
        value null, not yet implemented
  * Outputs:
      * a map of complexes,

Description
===========

Since Tor is a bifunctor, there are two different connecting maps. The first
comes from applying the covariant functor $M \otimes_S -$ to a short exact
sequence of modules.  The second comes from applying the covariant functor $-
\otimes_S M$ to a short exact sequence of modules. More explicitly, given the
short exact sequence

$\phantom{WWWW} 0 \leftarrow C \xleftarrow{g} B  \xleftarrow{f} A \leftarrow 0,
$

the $i$-th connecting homomorphism is, in the first case, a map
$\operatorname{Tor}^S_i(M, C) \to \operatorname{Tor}^S_{i-1}(M, A)$ and, in the
second case, a map $\operatorname{Tor}^S_i(A, M) \to
\operatorname{Tor}^S_{i-1}(C, M)$.

As a first example, let $\Bbbk$ be the base field as an $S$-module. Applying
the functor $\Bbbk \otimes_S -$ to a short exact sequence of modules

$\phantom{WWWW} 0 \leftarrow S/(I+J) \leftarrow S/I \oplus S/J  \leftarrow S/I
\cap J \leftarrow 0 $

gives rise to the long exact sequence of Tor modules having the form

$\phantom{WWWW} \dotsb \leftarrow \operatorname{Tor}_{i-1}(\Bbbk, S/(I+J))
\xleftarrow{\delta_{i}} \operatorname{Tor}_i(\Bbbk, S/I \cap J) \leftarrow
\operatorname{Tor}_i(\Bbbk, S/I \oplus S/J) \leftarrow
\operatorname{Tor}_i(\Bbbk, S/(I+J)) \leftarrow \dotsb. $

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..d];                                                       |
+-----------------------------------------------------------------------------+
|i2 : I = ideal(c^3-b*d^2, b*c-a*d)                                           |
|                                                                             |
|             3      2                                                        |
|o2 = ideal (c  - b*d , b*c - a*d)                                            |
|                                                                             |
|o2 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i3 : J = ideal(a*c^2-b^2*d, b^3-a^2*c)                                       |
|                                                                             |
|               2    2    3    2                                              |
|o3 = ideal (a*c  - b d, b  - a c)                                            |
|                                                                             |
|o3 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i4 : g = map(S^1/(I+J), S^1/I ++ S^1/J, {{1,1}});                            |
|                                                                             |
|o4 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i5 : f = map(S^1/I ++ S^1/J, S^1/intersect(I,J), {{1},{-1}});                |
|                                                                             |
|o5 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i6 : assert isShortExactSequence(g,f)                                        |
+-----------------------------------------------------------------------------+
|i7 : kk = coker vars S                                                       |
|                                                                             |
|o7 = cokernel | a b c d |                                                    |
|                                                                             |
|                            1                                                |
|o7 : S-module, quotient of S                                                 |
+-----------------------------------------------------------------------------+
|i8 : delta = connectingTorMap(kk, g, f)                                      |
|                                                                             |
|o8 = 2 : subquotient ({1} | -b 0  -c 0  0  -d bc2-acd c2d  c3                |
|                      {1} | a  -c 0  0  -d 0  0       -bd2 -bcd              |
|                      {1} | 0  b  a  -d 0  0  0       0    0                 |
|                      {1} | 0  0  0  c  b  a  0       0    0                 |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|     3 : subquotient ({2} | c  d  0  0  0    c3       ac2d-b2d2              |
|                      {2} | -b 0  0  d  -c2d -bc2+acd 0                      |
|                      {2} | a  0  d  0  bd2  0        0                      |
|                      {2} | 0  -b 0  -c c3   -b2d     0                      |
|                      {2} | 0  a  -c 0  -bcd b2c      0                      |
|                      {2} | 0  0  b  a  0    0        0                      |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|-b2d |, {1} | -b -c 0  -d 0                                                  |
|b2c  |  {1} | a  0  -c 0  -d                                                 |
|0    |  {1} | 0  a  b  0  0                                                  |
|0    |  {1} | 0  0  0  a  b                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|ac3-b2cd b2c2-abcd abc2-a2cd                                                 |
|0        0         0                                                         |
|0        0         0                                                         |
|0        0         0                                                         |
|0        0         0                                                         |
|0        0         0                                                         |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|0  ac2d-b2d2 ac3-b2cd abc2-a2cd b3c-ab2d 0         0        0         0      |
|0  0         0        0         0        ac2d-b2d2 ac3-b2cd abc2-a2cd b3c-   |
|-d 0         0        0         0        0         0        0         0      |
|c  0         0        0         0        0         0        0         0      |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|b3c-ab2d 0         0        -bc3+b2d2 0         0        -c3d  -c4   b2cd    |
|0        ac2d-b2d2 ac3-b2cd b2c2-abcd abc2-a2cd b3c-ab2d bc2d  bc3   -b3d    |
|0        0         0        0         0         0        -b2d2 -b2cd b3c     |
|0        0         0        0         0         0        0     0     0       |
|0        0         0        0         0         0        0     0     0       |
|0        0         0        0         0         0        0     0     0       |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|     0         0        0         0        0         0        0         0    |
|ab2d 0         0        0         0        0         0        0         0    |
|     ac2d-b2d2 ac3-b2cd abc2-a2cd b3c-ab2d 0         0        0         0    |
|     0         0        0         0        ac2d-b2d2 ac3-b2cd abc2-a2cd b3c- |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|0         -bc2d+acd2 0         -c2d2 |, {2} | c  d  0  0  ac2d-b2d2 ac3-b2cd |
|0         0          0         0     |  {2} | -b 0  d  0  0         0        |
|0         0          0         0     |  {2} | a  0  0  d  0         0        |
|ac2d-b2d2 b2c2-abcd  abc2-a2cd bc2d  |  {2} | 0  -b -c 0  0         0        |
|0         0          0         -b2d2 |  {2} | 0  a  0  -c 0         0        |
|0         0          0         0     |  {2} | 0  0  a  b  0         0        |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|     |) <----------------------------------------------------- subquotient ({|
|     |     {2} | 0 0 0 0 0 0 0  0 0  0 0  0 0 0  0 0 0 0 0 |                {|
|     |     {2} | 0 0 0 0 0 0 0  0 0  0 0  0 0 0  0 0 0 0 0 |                {|
|ab2d |     {2} | 0 0 0 0 0 0 0  0 0  0 0  0 0 0  0 0 0 0 0 |                {|
|           {2} | 0 0 0 0 0 0 0  0 0  0 0  0 0 0  0 0 0 0 0 |                {|
|           {2} | 0 0 0 0 0 0 0  0 0  0 0  0 0 0  0 0 0 0 0 |                {|
|           {2} | 0 0 0 0 0 0 0  0 0  0 0  0 0 0  0 0 0 0 0 |                 |
|           {4} | 0 0 0 0 0 0 0  0 0  0 0  0 0 -1 0 0 0 0 0 |                 |
|           {4} | 0 0 0 0 0 0 0  0 0  0 -1 0 0 0  0 0 0 0 0 |                 |
|           {4} | 0 0 0 0 0 0 -1 0 0  0 0  0 0 0  0 0 0 0 0 |                 |
|           {4} | 0 0 0 0 0 0 0  0 -1 0 0  0 0 0  0 0 0 0 0 |                 |
|                                                                             |
| abc2-a2cd b3c-ab2d 0         0        0         0        0         0        |
| 0         0        ac2d-b2d2 ac3-b2cd abc2-a2cd b3c-ab2d 0         0        |
| 0         0        0         0        0         0        ac2d-b2d2 ac3-b2cd |
| 0         0        0         0        0         0        0         0        |
| 0         0        0         0        0         0        0         0        |
| 0         0        0         0        0         0        0         0        |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|2} | c  d  0  0  bc-ad 0                                                     |
|2} | -b 0  0  d  0     bc-ad                                                 |
|2} | a  0  d  0  0     0                                                     |
|2} | 0  -b 0  -c 0     0                                                     |
|2} | 0  a  -c 0  0     0                                                     |
|2} | 0  0  b  a  0     0                                                     |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|0         0        0                                                         |
|0         0        0                                                         |
|abc2-a2cd b3c-ab2d 0                                                         |
|0         0        ac2d-b2d2                                                 |
|0         0        0                                                         |
|0         0        0                                                         |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|-d2 cd  bd  0     0   0   d2  c2  c3-bd2 ac2-b2d b3-a2c 0      0    |, {2} | |
|c2  -bd -ac 0     -cd d2  0   0   0      0       0      0      0    |  {2} | |
|-bd bc  b2  0     c2  -cd 0   0   0      0       0      c3-bd2 d3   |  {2} | |
|0   0   0   bc-ad c2  -cd -bd -ac 0      0       0      0      0    |  {2} | |
|0   0   0   0     -bd c2  bc  b2  0      0       0      0      -cd2 |  {2} | |
|0   0   0   0     0   0   0   0   0      0       0      0      c3   |  {2} | |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|0        0         0        0         0        0         0        0          |
|0        0         0        0         0        0         0        0          |
|0        0         0        0         0        0         0        0          |
|ac3-b2cd abc2-a2cd b3c-ab2d 0         0        0         0        0          |
|0        0         0        ac2d-b2d2 ac3-b2cd abc2-a2cd b3c-ab2d 0          |
|0        0         0        0         0        0         0        ac2d-b2d2  |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
| c  d  0  0  c3-bd2 bc-ad ac2-b2d b3-a2c 0      0     0       0      0       |
| -b 0  d  0  0      0     0       0      c3-bd2 bc-ad ac2-b2d b3-a2c 0       |
| a  0  0  d  0      0     0       0      0      0     0       0      c3-     |
| 0  -b -c 0  0      0     0       0      0      0     0       0      0       |
| 0  a  0  -c 0      0     0       0      0      0     0       0      0       |
| 0  0  a  b  0      0     0       0      0      0     0       0      0       |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|0        0         0        |) <----------------------------------------     |
|0        0         0        |     {3} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|0        0         0        |     {3} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|0        0         0        |     {3} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|0        0         0        |     {3} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|ac3-b2cd abc2-a2cd b3c-ab2d |     {5} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {5} | 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|                                  {6} | 0 0 0 0 0 0  0 0 0 0 0 0 0 0 |       |
|-----------------------------------------------------------------------------|
|    0     0       0      0      0     0       0      0      0     0       0  |
|    0     0       0      0      0     0       0      0      0     0       0  |
|bd2 bc-ad ac2-b2d b3-a2c 0      0     0       0      0      0     0       0  |
|    0     0       0      c3-bd2 bc-ad ac2-b2d b3-a2c 0      0     0       0  |
|    0     0       0      0      0     0       0      c3-bd2 bc-ad ac2-b2d b3-|
|    0     0       0      0      0     0       0      0      0     0       0  |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
| subquotient ({3} | -d bc-ad 0     0     -d2 -c2 c3-bd2 ac2-b2d b3-a2c 0     |
|              {3} | c  0     bc-ad 0     cd  bd  0      0       0      c3-bd2|
|              {3} | -b 0     0     bc-ad -bd -ac 0      0       0      0     |
|              {3} | a  0     0     0     bc  b2  0      0       0      0     |
|-----------------------------------------------------------------------------|
|    0      0     0       0      |) : 2                                       |
|    0      0     0       0      |                                            |
|    0      0     0       0      |                                            |
|    0      0     0       0      |                                            |
|a2c 0      0     0       0      |                                            |
|    c3-bd2 bc-ad ac2-b2d b3-a2c |                                            |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
| 0       0      0      0      |, {3} | -d c3-bd2 bc-ad ac2-b2d b3-a2c 0      |
| ac2-b2d b3-a2c 0      0      |  {3} | c  0      0     0       0      c3-bd2 |
| 0       0      c3-bd2 0      |  {3} | -b 0      0     0       0      0      |
| 0       0      0      c3-bd2 |  {3} | a  0      0     0       0      0      |
|-----------------------------------------------------------------------------|
|0     0       0      0      0     0       0      0      0     0       0      |
|bc-ad ac2-b2d b3-a2c 0      0     0       0      0      0     0       0      |
|0     0       0      c3-bd2 bc-ad ac2-b2d b3-a2c 0      0     0       0      |
|0     0       0      0      0     0       0      c3-bd2 bc-ad ac2-b2d b3-a2c |
|-----------------------------------------------------------------------------|
||) : 3                                                                       |
||                                                                            |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i9 : assert isWellDefined delta                                              |
+-----------------------------------------------------------------------------+
|i10 : assert(source delta_2 == Tor_2(kk, target g))                          |
+-----------------------------------------------------------------------------+
|i11 : assert(target delta_2 == Tor_1(kk, source f))                          |
+-----------------------------------------------------------------------------+
|i12 : prune delta                                                            |
|                                                                             |
|o12 = 2 : cokernel {4} | d c b a 0 0 0 0 0 0 0 0 0                           |
|                   {4} | 0 0 0 0 d c b a 0 0 0 0 0                           |
|                   {4} | 0 0 0 0 0 0 0 0 d c b a 0                           |
|                   {4} | 0 0 0 0 0 0 0 0 0 0 0 0 d                           |
|                                                                             |
|                                                                             |
|      3 : cokernel {5} | d c b a 0 0 0 0 0 0 0 0 |                           |
|                   {5} | 0 0 0 0 d c b a 0 0 0 0 |                           |
|                   {6} | 0 0 0 0 0 0 0 0 d c b a |                           |
|                                                                             |
|                                                                             |
|o12 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|0 0 0 | <----------------------- cokernel {4} | d c b a 0 0 0 0 0 0 0 0 0 0 0|
|0 0 0 |    {4} | 0  0  0  -1 |            {4} | 0 0 0 0 d c b a 0 0 0 0 0 0 0|
|0 0 0 |    {4} | 0  0  -1 0  |            {4} | 0 0 0 0 0 0 0 0 d c b a 0 0 0|
|c b a |    {4} | -1 0  0  0  |            {4} | 0 0 0 0 0 0 0 0 0 0 0 0 d c b|
|           {4} | 0  -1 0  0  |                                               |
|                                                                             |
|<-------------- cokernel {5} | d c b a | : 3                                 |
|   {5} | 0  |                                                                |
|   {5} | -1 |                                                                |
|   {6} | 0  |                                                                |
|-----------------------------------------------------------------------------|
|0 | : 2                                                                      |
|0 |                                                                          |
|0 |                                                                          |
|a |                                                                          |
+-----------------------------------------------------------------------------+

The connecting homomorphism fits into a natural long exact sequence in Tor.

+---------------------------------------------------------+
|i13 : F = freeResolution kk;                             |
+---------------------------------------------------------+
|i14 : LES = longExactSequence(F ** g, F ** f);           |
+---------------------------------------------------------+
|i15 : assert all(3, i -> dd^LES_(3*(i+1)) == delta_(i+1))|
+---------------------------------------------------------+
|i16 : assert(HH LES == 0)                                |
+---------------------------------------------------------+

As a second example, applying the functor $- \otimes_S \Bbbk$ to a short exact
sequence of modules

$\phantom{WWWW} 0 \leftarrow S/(I+J) \leftarrow S/I \oplus S/J  \leftarrow S/I
\cap J \leftarrow 0 $

gives rise to the long exact sequence of Tor modules having the form

$\phantom{WWWW} \dotsb \leftarrow \operatorname{Tor}_{i-1}(S/(I+J), \Bbbk)
\xleftarrow{\delta_{i}} \operatorname{Tor}_i(S/I \cap J, \Bbbk) \leftarrow
\operatorname{Tor}_i(S/I \oplus S/J, \Bbbk) \leftarrow
\operatorname{Tor}_i(S/(I+J), \Bbbk) \leftarrow \dotsb. $

+-----------------------------------------------------------------------------+
|i17 : delta' = connectingTorMap(g, f, kk)                                    |
|                                                                             |
|o17 = 2 : cokernel {4} | 0 0 0 a b c d 0 0 0 0 0 0                           |
|                   {4} | 0 0 0 0 0 0 0 a b c d 0 0                           |
|                   {4} | 0 0 0 0 0 0 0 0 0 0 0 a b                           |
|                   {4} | 0 0 0 0 0 0 0 0 0 0 0 0 0                           |
|                                                                             |
|                                                                             |
|      3 : cokernel {5} | a b c d 0 0 0 0 0 0 0 0 |                           |
|                   {5} | 0 0 0 0 a b c d 0 0 0 0 |                           |
|                   {6} | 0 0 0 0 0 0 0 0 a b c d |                           |
|                                                                             |
|                                                                             |
|o17 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|0 0 0 0 0 0 | <--------------------- cokernel {4} | 0 a b c d 0 0 0 0 0 0 0 0|
|0 0 0 0 0 0 |    {4} | -1 0  0 0 |            {4} | 0 0 0 0 0 a b c d 0 0 0 0|
|c d 0 0 0 0 |    {4} | 0  -1 0 0 |            {4} | 0 0 0 0 0 0 0 0 0 a b c d|
|0 0 a b c d |    {4} | 0  0  1 0 |            {4} | 0 0 0 0 0 0 0 0 0 0 0 0 0|
|                 {4} | 0  0  0 1 |                                           |
|                                                                             |
|<------------- cokernel {5} | a b c d | : 3                                  |
|   {5} | 1 |                                                                 |
|   {5} | 0 |                                                                 |
|   {6} | 0 |                                                                 |
|-----------------------------------------------------------------------------|
|0 0 0 0 | : 2                                                                |
|0 0 0 0 |                                                                    |
|0 0 0 0 |                                                                    |
|a b c d |                                                                    |
+-----------------------------------------------------------------------------+
|i18 : assert isWellDefined delta'                                            |
+-----------------------------------------------------------------------------+
|i19 : (g',f') = horseshoeResolution(g,f);                                    |
+-----------------------------------------------------------------------------+
|i20 : assert isShortExactSequence(g',f')                                     |
+-----------------------------------------------------------------------------+
|i21 : LES' = longExactSequence(g' ** kk, f' ** kk);                          |
+-----------------------------------------------------------------------------+
|i22 : assert(HH LES' == 0)                                                   |
+-----------------------------------------------------------------------------+
|i23 : assert all(3, i -> dd^LES'_(3*(i+1)) == delta'_(i+1))                  |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Tor -- information about functorial
    properties
  * connectingMap, --
    construct the connecting homomorphism on homology
  * isShortExactSequence -- whether a
    chain complex is a short exact sequence
  * longExactSequence, --
    make the long exact sequence in homology
  * Tor (Macaulay2Doc) -- Tor module
  * Working with Ext -- information about functorial
    properties

Ways to use this method:
========================

  * "connectingTorMap(Matrix,Matrix,Module)"
  * connectingTorMap(Module,Matrix,Matrix)
    -- makes the connecting
    maps in Tor

cylinder -- make the mapping cylinder of a morphism of chain complexes
**********************************************************************

Synopsis
========

  * Usage:
        cylinder f
  * Inputs:
      * f, a map of complexes, which is a morphism of
        complexes
  * Outputs:
      * a complex,

Description
===========

Given a morphism $f : B \to C$, the mapping cylinder is the complex whose the
$i$-th term is $B_{i-1} \oplus B_i \oplus C_i$ and whose $i$-th differential is
given in block form by matrix \{\{ - dd^B_{i-1}, 0, 0 \}, \{ -id_{B_{i-1}},
dd^B_i, 0 \}, \{ f_{i-1}, 0, dd^C_i\}\}. Alternatively, the cylinder is the
mapping cone of the morphism $g : B \to B \oplus C$ given in block form by
matrix\{\{-id_B\}, \{f\}\}.

A map between modules induces a map between their free resolutions, and we
compute the associated mapping cylinder.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/32003[x,y,z];                                                    |
+-----------------------------------------------------------------------------+
|i2 : M = ideal vars S                                                        |
|                                                                             |
|o2 = ideal (x, y, z)                                                         |
|                                                                             |
|o2 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i3 : B = freeResolution(S^1/M^2)                                             |
|                                                                             |
|      1      6      8      3                                                 |
|o3 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : C = freeResolution(S^1/M)                                               |
|                                                                             |
|      1      3      3      1                                                 |
|o4 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o4 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i5 : f = extend(C,B,id_(S^1))                                                |
|                                                                             |
|          1             1                                                    |
|o5 = 0 : S  <--------- S  : 0                                                |
|               | 1 |                                                         |
|                                                                             |
|          3                           6                                      |
|     1 : S  <----------------------- S  : 1                                  |
|               {1} | x y 0 0 0 0 |                                           |
|               {1} | 0 0 y 0 0 0 |                                           |
|               {1} | 0 0 0 x y z |                                           |
|                                                                             |
|          3                               8                                  |
|     2 : S  <--------------------------- S  : 2                              |
|               {2} | 0 y 0 0 0 0 0 0 |                                       |
|               {2} | 0 0 x y 0 0 0 0 |                                       |
|               {2} | 0 0 0 0 0 y 0 0 |                                       |
|                                                                             |
|          1                     3                                            |
|     3 : S  <----------------- S  : 3                                        |
|               {3} | 0 y 0 |                                                 |
|                                                                             |
|o5 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i6 : cylf = cylinder f                                                       |
|                                                                             |
|      2      10      17      12      3                                       |
|o6 = S  <-- S   <-- S   <-- S   <-- S                                        |
|                                                                             |
|     0      1       2       3       4                                        |
|                                                                             |
|o6 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i7 : dd^cylf                                                                 |
|                                                                             |
|          2                                      10                          |
|o7 = 0 : S  <---------------------------------- S   : 1                      |
|               | -1 x2 xy y2 xz yz z2 0 0 0 |                                |
|               | 1  0  0  0  0  0  0  x y z |                                |
|                                                                             |
|          10                                                                 |
|     1 : S   <---------------------------------------------------------------|
|                {0} | -x2 -xy -y2 -xz -yz -z2 0  0  0  0  0  0  0  0  0  0  0|
|                {2} | -1  0   0   0   0   0   -y 0  -z 0  0  0  0  0  0  0  0|
|                {2} | 0   -1  0   0   0   0   x  -y 0  -z 0  0  0  0  0  0  0|
|                {2} | 0   0   -1  0   0   0   0  x  0  0  0  -z 0  0  0  0  0|
|                {2} | 0   0   0   -1  0   0   0  0  x  y  -y 0  -z 0  0  0  0|
|                {2} | 0   0   0   0   -1  0   0  0  0  0  x  y  0  -z 0  0  0|
|                {2} | 0   0   0   0   0   -1  0  0  0  0  0  0  x  y  0  0  0|
|                {1} | x   y   0   0   0   0   0  0  0  0  0  0  0  0  -y -z 0|
|                {1} | 0   0   y   0   0   0   0  0  0  0  0  0  0  0  x  0  -|
|                {1} | 0   0   0   x   y   z   0  0  0  0  0  0  0  0  0  x  y|
|                                                                             |
|          17                                                   12            |
|     2 : S   <----------------------------------------------- S   : 3        |
|                {2} | y  0  z  0  0  0  0  0  0  0  0  0  |                  |
|                {2} | -x y  0  z  0  0  0  0  0  0  0  0  |                  |
|                {2} | 0  -x 0  0  0  z  0  0  0  0  0  0  |                  |
|                {2} | 0  0  -x -y y  0  z  0  0  0  0  0  |                  |
|                {2} | 0  0  0  0  -x -y 0  z  0  0  0  0  |                  |
|                {2} | 0  0  0  0  0  0  -x -y 0  0  0  0  |                  |
|                {3} | -1 0  0  0  0  0  0  0  z  0  0  0  |                  |
|                {3} | 0  -1 0  0  0  0  0  0  0  z  0  0  |                  |
|                {3} | 0  0  -1 0  0  0  0  0  -y 0  0  0  |                  |
|                {3} | 0  0  0  -1 0  0  0  0  x  -y 0  0  |                  |
|                {3} | 0  0  0  0  -1 0  0  0  0  -y z  0  |                  |
|                {3} | 0  0  0  0  0  -1 0  0  0  x  0  0  |                  |
|                {3} | 0  0  0  0  0  0  -1 0  0  0  -y 0  |                  |
|                {3} | 0  0  0  0  0  0  0  -1 0  0  x  0  |                  |
|                {2} | 0  y  0  0  0  0  0  0  0  0  0  z  |                  |
|                {2} | 0  0  x  y  0  0  0  0  0  0  0  -y |                  |
|                {2} | 0  0  0  0  0  y  0  0  0  0  0  x  |                  |
|                                                                             |
|          12                        3                                        |
|     3 : S   <-------------------- S  : 4                                    |
|                {3} | -z 0  0  |                                             |
|                {3} | 0  -z 0  |                                             |
|                {3} | y  0  0  |                                             |
|                {3} | -x y  0  |                                             |
|                {3} | 0  y  -z |                                             |
|                {3} | 0  -x 0  |                                             |
|                {3} | 0  0  y  |                                             |
|                {3} | 0  0  -x |                                             |
|                {4} | -1 0  0  |                                             |
|                {4} | 0  -1 0  |                                             |
|                {4} | 0  0  -1 |                                             |
|                {3} | 0  y  0  |                                             |
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|       17                                                                    |
|----- S   : 2                                                                |
|  |                                                                          |
|  |                                                                          |
|  |                                                                          |
|  |                                                                          |
|  |                                                                          |
|  |                                                                          |
|  |                                                                          |
|  |                                                                          |
|z |                                                                          |
|  |                                                                          |
+-----------------------------------------------------------------------------+
|i8 : assert isWellDefined cylf                                               |
+-----------------------------------------------------------------------------+

The mapping cylinder fits into a canonical short exact sequence of chain
complexes, $$0 \to B \to cyl(f) \to cone(f) \to 0.$$

+-------------------------------------------------------------------+
|i9 : Cf = cone f                                                   |
|                                                                   |
|      1      4      9      9      3                                |
|o9 = S  <-- S  <-- S  <-- S  <-- S                                 |
|                                                                   |
|     0      1      2      3      4                                 |
|                                                                   |
|o9 : Complex                                                       |
+-------------------------------------------------------------------+
|i10 : g = canonicalMap(cylf, B)                                    |
|                                                                   |
|           2             1                                         |
|o10 = 0 : S  <--------- S  : 0                                     |
|                | 1 |                                              |
|                | 0 |                                              |
|                                                                   |
|           10                           6                          |
|      1 : S   <----------------------- S  : 1                      |
|                 {0} | 0 0 0 0 0 0 |                               |
|                 {2} | 1 0 0 0 0 0 |                               |
|                 {2} | 0 1 0 0 0 0 |                               |
|                 {2} | 0 0 1 0 0 0 |                               |
|                 {2} | 0 0 0 1 0 0 |                               |
|                 {2} | 0 0 0 0 1 0 |                               |
|                 {2} | 0 0 0 0 0 1 |                               |
|                 {1} | 0 0 0 0 0 0 |                               |
|                 {1} | 0 0 0 0 0 0 |                               |
|                 {1} | 0 0 0 0 0 0 |                               |
|                                                                   |
|           17                               8                      |
|      2 : S   <--------------------------- S  : 2                  |
|                 {2} | 0 0 0 0 0 0 0 0 |                           |
|                 {2} | 0 0 0 0 0 0 0 0 |                           |
|                 {2} | 0 0 0 0 0 0 0 0 |                           |
|                 {2} | 0 0 0 0 0 0 0 0 |                           |
|                 {2} | 0 0 0 0 0 0 0 0 |                           |
|                 {2} | 0 0 0 0 0 0 0 0 |                           |
|                 {3} | 1 0 0 0 0 0 0 0 |                           |
|                 {3} | 0 1 0 0 0 0 0 0 |                           |
|                 {3} | 0 0 1 0 0 0 0 0 |                           |
|                 {3} | 0 0 0 1 0 0 0 0 |                           |
|                 {3} | 0 0 0 0 1 0 0 0 |                           |
|                 {3} | 0 0 0 0 0 1 0 0 |                           |
|                 {3} | 0 0 0 0 0 0 1 0 |                           |
|                 {3} | 0 0 0 0 0 0 0 1 |                           |
|                 {2} | 0 0 0 0 0 0 0 0 |                           |
|                 {2} | 0 0 0 0 0 0 0 0 |                           |
|                 {2} | 0 0 0 0 0 0 0 0 |                           |
|                                                                   |
|           12                     3                                |
|      3 : S   <----------------- S  : 3                            |
|                 {3} | 0 0 0 |                                     |
|                 {3} | 0 0 0 |                                     |
|                 {3} | 0 0 0 |                                     |
|                 {3} | 0 0 0 |                                     |
|                 {3} | 0 0 0 |                                     |
|                 {3} | 0 0 0 |                                     |
|                 {3} | 0 0 0 |                                     |
|                 {3} | 0 0 0 |                                     |
|                 {4} | 1 0 0 |                                     |
|                 {4} | 0 1 0 |                                     |
|                 {4} | 0 0 1 |                                     |
|                 {3} | 0 0 0 |                                     |
|                                                                   |
|o10 : ComplexMap                                                   |
+-------------------------------------------------------------------+
|i11 : h = canonicalMap(Cf, cylf)                                   |
|                                                                   |
|           1               2                                       |
|o11 = 0 : S  <----------- S  : 0                                   |
|                | 0 1 |                                            |
|                                                                   |
|           4                                   10                  |
|      1 : S  <------------------------------- S   : 1              |
|                {0} | 1 0 0 0 0 0 0 0 0 0 |                        |
|                {1} | 0 0 0 0 0 0 0 1 0 0 |                        |
|                {1} | 0 0 0 0 0 0 0 0 1 0 |                        |
|                {1} | 0 0 0 0 0 0 0 0 0 1 |                        |
|                                                                   |
|           9                                                 17    |
|      2 : S  <--------------------------------------------- S   : 2|
|                {2} | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |          |
|                {2} | 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |          |
|                {2} | 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |          |
|                {2} | 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 |          |
|                {2} | 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |          |
|                {2} | 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 |          |
|                {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 |          |
|                {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 |          |
|                {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 |          |
|                                                                   |
|           9                                       12              |
|      3 : S  <----------------------------------- S   : 3          |
|                {3} | 1 0 0 0 0 0 0 0 0 0 0 0 |                    |
|                {3} | 0 1 0 0 0 0 0 0 0 0 0 0 |                    |
|                {3} | 0 0 1 0 0 0 0 0 0 0 0 0 |                    |
|                {3} | 0 0 0 1 0 0 0 0 0 0 0 0 |                    |
|                {3} | 0 0 0 0 1 0 0 0 0 0 0 0 |                    |
|                {3} | 0 0 0 0 0 1 0 0 0 0 0 0 |                    |
|                {3} | 0 0 0 0 0 0 1 0 0 0 0 0 |                    |
|                {3} | 0 0 0 0 0 0 0 1 0 0 0 0 |                    |
|                {3} | 0 0 0 0 0 0 0 0 0 0 0 1 |                    |
|                                                                   |
|           3                     3                                 |
|      4 : S  <----------------- S  : 4                             |
|                {4} | 1 0 0 |                                      |
|                {4} | 0 1 0 |                                      |
|                {4} | 0 0 1 |                                      |
|                                                                   |
|o11 : ComplexMap                                                   |
+-------------------------------------------------------------------+
|i12 : assert(isWellDefined g and isWellDefined h)                  |
+-------------------------------------------------------------------+
|i13 : assert(isShortExactSequence(h,g))                            |
+-------------------------------------------------------------------+

The alternative interpretation of the cylinder, defined above, can be
demonstrated as follows.

+---------------------------------------------------------+
|i14 : g = map(B ++ C, B, {{-id_B},{f}})                  |
|                                                         |
|           2              1                              |
|o14 = 0 : S  <---------- S  : 0                          |
|                | -1 |                                   |
|                | 1  |                                   |
|                                                         |
|           9                                 6           |
|      1 : S  <----------------------------- S  : 1       |
|                {2} | -1 0  0  0  0  0  |                |
|                {2} | 0  -1 0  0  0  0  |                |
|                {2} | 0  0  -1 0  0  0  |                |
|                {2} | 0  0  0  -1 0  0  |                |
|                {2} | 0  0  0  0  -1 0  |                |
|                {2} | 0  0  0  0  0  -1 |                |
|                {1} | x  y  0  0  0  0  |                |
|                {1} | 0  0  y  0  0  0  |                |
|                {1} | 0  0  0  x  y  z  |                |
|                                                         |
|           11                                       8    |
|      2 : S   <----------------------------------- S  : 2|
|                 {3} | -1 0  0  0  0  0  0  0  |         |
|                 {3} | 0  -1 0  0  0  0  0  0  |         |
|                 {3} | 0  0  -1 0  0  0  0  0  |         |
|                 {3} | 0  0  0  -1 0  0  0  0  |         |
|                 {3} | 0  0  0  0  -1 0  0  0  |         |
|                 {3} | 0  0  0  0  0  -1 0  0  |         |
|                 {3} | 0  0  0  0  0  0  -1 0  |         |
|                 {3} | 0  0  0  0  0  0  0  -1 |         |
|                 {2} | 0  y  0  0  0  0  0  0  |         |
|                 {2} | 0  0  x  y  0  0  0  0  |         |
|                 {2} | 0  0  0  0  0  y  0  0  |         |
|                                                         |
|           4                        3                    |
|      3 : S  <-------------------- S  : 3                |
|                {4} | -1 0  0  |                         |
|                {4} | 0  -1 0  |                         |
|                {4} | 0  0  -1 |                         |
|                {3} | 0  y  0  |                         |
|                                                         |
|o14 : ComplexMap                                         |
+---------------------------------------------------------+
|i15 : cone g == cylf                                     |
|                                                         |
|o15 = true                                               |
+---------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * cone(ComplexMap) -- make the mapping cone of a
    morphism of chain complexes
  * extend(Complex,Complex,Matrix)
    -- extend a map of
    modules to a map of chain complexes
  * freeResolution(Module) -- compute a free resolution
    of a module or ideal
  * canonicalMap -- gets the natural map arising from
    various constructions
  * isShortExactSequence -- whether a
    chain complex is a short exact sequence

Ways to use cylinder :
======================

  * "cylinder(ComplexMap)"

For the programmer
==================

The object cylinder, is a method function (Macaulay2Doc).

degree(ComplexMap) -- get the degree of a map of chain complexes
****************************************************************

Synopsis
========

  * Function: degree (Macaulay2Doc),
  * Usage:
        degree f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * an integer (Macaulay2Doc),

Description
===========

A complex map $f : C \to D$ of degree $d$ is a sequence of of maps $f_i : C_i
\to D_{i+d}$. This method returns $d$.

The degree of the differential of a complex is always -1.

+-------------------------------+
|i1 : R = ZZ/101[a..d];         |
+-------------------------------+
|i2 : I = ideal(a^2, b^2, c^2)  |
|                               |
|             2   2   2         |
|o2 = ideal (a , b , c )        |
|                               |
|o2 : Ideal of R                |
+-------------------------------+
|i3 : FI = freeResolution I     |
|                               |
|      1      3      3      1   |
|o3 = R  <-- R  <-- R  <-- R    |
|                               |
|     0      1      2      3    |
|                               |
|o3 : Complex                   |
+-------------------------------+
|i4 : assert(degree dd^FI == -1)|
+-------------------------------+
+-----------------------------------------------------------------------------+
|i5 : FJ = freeResolution (I + ideal(a*b*c))                                  |
|                                                                             |
|      1      4      6      3                                                 |
|o5 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o5 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i6 : f = randomComplexMap(FJ, FI, Cycle=>true, Degree => -2)                 |
|                                                                             |
|                    1                                                        |
|o6 = -2 : 0 <----- R  : 0                                                    |
|               0                                                             |
|                                                                             |
|                    3                                                        |
|     -1 : 0 <----- R  : 1                                                    |
|               0                                                             |
|                                                                             |
|          1                                                                  |
|     0 : R  <----------------------------------------------------------------|
|               | 18a4+44a3b-29a2b2+8ab3+6b4+38a3c+50a2bc-48ab2c+50b3c-32a2c2+|
|                                                                             |
|          4                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {2} | 24a4-36a3b+19a2b2-29ab3-18b4-30a3c+19a2bc-24ab2c-13b3c-2|
|               {2} | 19a4-16a3b-23a2b2+36ab3-3b4+7a3c+39a2bc+35ab2c+22b3c-17a|
|               {2} | 27a4-22a3b-32a2b2+39ab3+36b4+32a3c-20a2bc+9b3c-30a2c2-49|
|               {3} | 40a3-22a2b+30ab2-47b3+10a2c+13abc+18b2c-13ac2-30bc2-48c3|
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|4abc2-24b2c2+17ac3+22bc3+43c4+31a3d+49a2bd+4ab2d-23b3d+12a2cd-3abcd+7b2cd-20a|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|9a2c2-16abc2-15b2c2+34ac3+38bc3+45c4-29a3d-10a2bd-38ab2d-43b3d-8a2cd+39abcd-2|
|2c2-38abc2-23b2c2+11ac3+29bc3-13c4+15a3d+43a2bd+11ab2d-47b3d-11a2cd+33abcd-7b|
|abc2+4b2c2+17ac3+22bc3+43c4-9a3d+24a2bd+33ab2d-39b3d-48a2cd-33abcd+13b2cd-20a|
|+7a2d-17abd-28b2d+3acd+26bcd+30c2d-41ad2-bd2-37cd2                           |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|c2d-49bc2d-8c3d+37a2d2+45abd2+9b2d2+44acd2-11bcd2+36c2d2-39ad3-8bd3-3cd3-22d4|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|8b2cd+19ac2d+2bc2d-34c3d-22a2d2+21abd2-47b2d2-47acd2+16bcd2-48c2d2-39ad3+22bd|
|2cd+46ac2d-47bc2d-10c3d+48a2d2+40abd2+2b2d2-28acd2+15bcd2+30c2d2+ad3-37bd3-18|
|c2d-49bc2d-8c3d-15a2d2-19abd2-26b2d2+44acd2-11bcd2+36c2d2-39ad3-8bd3-3cd3-22d|
|                                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
| -32a4+20a3b+50a2b2-36ab3+3b4+23a3c+22a2bc+12ab2c-22b3c-18a2c2-11abc2-7b2c2-2|
|                                                                             |
|                  1                                                          |
|---------------- R  : 3                                                      |
|3-47cd3+47d4 |                                                               |
|cd3+39d4     |                                                               |
|4            |                                                               |
|             |                                                               |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|9ac3+12bc3-15c4+39a3d-6a2bd-11ab2d+47b3d-20a2cd-5abcd+7b2cd-38bc2d+4c3d+14a2d|
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|2-40abd2-2b2d2+29acd2-15bcd2+5c2d2-ad3+37bd3+18cd3-39d4 24a4-36a3b+6a2b2-25ab|
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|3+9b4-30a3c-42a2bc-16ab2c-23b3c-20a2c2+29abc2-40b2c2+28ac3-45bc3+47c4-29a3d-1|
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|0a2bd+16ab2d-6b3d-8a2cd+46abcd+25b2cd-21ac2d-20bc2d+7c3d-22a2d2+21abd2+15b2d2|
|-----------------------------------------------------------------------------|
|                                                3                            |
|---------------------------------------------- R  : 2                        |
|-47acd2-25bcd2+c2d2-39ad3+22bd3-47cd3+47d4 |                                 |
+-----------------------------------------------------------------------------+
|i7 : assert(degree f == -2)                                                  |
+-----------------------------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * source(ComplexMap) -- get the source of a
    map of chain complexes
  * target(ComplexMap) -- get the target of a
    map of chain complexes
  * freeResolution(Ideal) -- compute a free resolution
    of a module or ideal
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes

Ways to use this method:
========================

  * degree(ComplexMap) -- get the degree of a
    map of chain complexes

differential of a chain complex -- get the maps between the terms in a complex
******************************************************************************

Synopsis
========

  * Usage:
        dd^C
        dd_C
  * Inputs:
      * C, a complex,
  * Outputs:
      * a map of complexes, a map of degree -1

A chain complex is a sequence of modules connected by homomorphisms, called
differentials, such that the composition of any two consecutive maps is zero.

One can access the differential of a complex as follows.

+---------------------------------------------+
|i1 : R = QQ[a..d];                           |
+---------------------------------------------+
|i2 : I = ideal(a*d-b*c, b^2-a*c, c^2-b*d);   |
|                                             |
|o2 : Ideal of R                              |
+---------------------------------------------+
|i3 : C = freeResolution(R^1/I)               |
|                                             |
|      1      3      2                        |
|o3 = R  <-- R  <-- R                         |
|                                             |
|     0      1      2                         |
|                                             |
|o3 : Complex                                 |
+---------------------------------------------+
|i4 : dd^C                                    |
|                                             |
|          1                             3    |
|o4 = 0 : R  <------------------------- R  : 1|
|               | b2-ac bc-ad c2-bd |         |
|                                             |
|          3                     2            |
|     1 : R  <----------------- R  : 2        |
|               {2} | -c d  |                 |
|               {2} | b  -c |                 |
|               {2} | -a b  |                 |
|                                             |
|o4 : ComplexMap                              |
+---------------------------------------------+
|i5 : C.dd                                    |
|                                             |
|          1                             3    |
|o5 = 0 : R  <------------------------- R  : 1|
|               | b2-ac bc-ad c2-bd |         |
|                                             |
|          3                     2            |
|     1 : R  <----------------- R  : 2        |
|               {2} | -c d  |                 |
|               {2} | b  -c |                 |
|               {2} | -a b  |                 |
|                                             |
|o5 : ComplexMap                              |
+---------------------------------------------+
|i6 : assert(dd^C === C.dd)                   |
+---------------------------------------------+
|i7 : assert(source dd^C === C)               |
+---------------------------------------------+
|i8 : assert(target dd^C === C)               |
+---------------------------------------------+
|i9 : assert(degree dd^C === -1)              |
+---------------------------------------------+

The composition of the differential with itself is zero.

+-------------------+
|i10 : (dd^C)^2 == 0|
|                   |
|o10 = true         |
+-------------------+

The individual maps between terms are indexed by their source.

+-----------------------------------+
|i11 : dd^C_2                       |
|                                   |
|o11 = {2} | -c d  |                |
|      {2} | b  -c |                |
|      {2} | -a b  |                |
|                                   |
|              3       2            |
|o11 : Matrix R  <--- R             |
+-----------------------------------+
|i12 : assert(source dd^C_2 === C_2)|
+-----------------------------------+
|i13 : assert(target dd^C_2 === C_1)|
+-----------------------------------+

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * ComplexMap _ ZZ -- access individual matrices in
    a complex map
  * Complex _ ZZ -- access individual object in a
    complex
  * source(ComplexMap) -- get the source of a
    map of chain complexes
  * target(ComplexMap) -- get the target of a
    map of chain complexes
  * degree(ComplexMap) -- get the degree of a
    map of chain complexes

directSum(Complex) -- direct sum of complexes
*********************************************

Synopsis
========

  * Function: directSum (Macaulay2Doc),
  * Usage:
        D = C1 ++ C2
        D = directSum(C1,C2,...)
        D = directSum(name1 => C1, name2 => C2, ...)
  * Inputs:
      * Ci, a complex,
  * Outputs:
      * D, a complex, the direct sum of the input complexes

Description
===========

The direct sum of two complexes is another complex.

+-------------------------------------------+
|i1 : S = ZZ/101[a,b,c];                    |
+-------------------------------------------+
|i2 : C1 = freeResolution coker vars S      |
|                                           |
|      1      3      3      1               |
|o2 = S  <-- S  <-- S  <-- S                |
|                                           |
|     0      1      2      3                |
|                                           |
|o2 : Complex                               |
+-------------------------------------------+
|i3 : C1 ++ complex(S^13)[-2]               |
|                                           |
|      1      3      16      1              |
|o3 = S  <-- S  <-- S   <-- S               |
|                                           |
|     0      1      2       3               |
|                                           |
|o3 : Complex                               |
+-------------------------------------------+
|i4 : C2 = complex (ideal(a,b,c))           |
|                                           |
|o4 = image | a b c |                       |
|                                           |
|     0                                     |
|                                           |
|o4 : Complex                               |
+-------------------------------------------+
|i5 : C1 ++ C2                              |
|                                           |
|                            3      3      1|
|o5 = image | 1 0 0 0 | <-- S  <-- S  <-- S |
|           | 0 a b c |                     |
|                           1      2      3 |
|     0                                     |
|                                           |
|o5 : Complex                               |
+-------------------------------------------+
|i6 : assert isWellDefined(C1 ++ C2)        |
+-------------------------------------------+

The direct sum of a sequence of complexes can be computed as follows.

+------------------------------------------------------------------+
|i7 : C3 = directSum(C1,C2,C2[-2])                                 |
|                                                                  |
|                            3                                    1|
|o7 = image | 1 0 0 0 | <-- S  <-- image {2} | 1 0 0 0 0 0 | <-- S |
|           | 0 a b c |                  {2} | 0 1 0 0 0 0 |       |
|                           1            {2} | 0 0 1 0 0 0 |     3 |
|     0                                  {0} | 0 0 0 a b c |       |
|                                                                  |
|                                  2                               |
|                                                                  |
|o7 : Complex                                                      |
+------------------------------------------------------------------+
|i8 : assert isWellDefined C3                                      |
+------------------------------------------------------------------+

The direct sum is an n-ary operator with projection and inclusion maps from
each component satisfying appropriate identities.

+--------------------------------------------------------------+
|i9 : C4 = directSum(first => C1, second => C2)                |
|                                                              |
|                            3      3      1                   |
|o9 = image | 1 0 0 0 | <-- S  <-- S  <-- S                    |
|           | 0 a b c |                                        |
|                           1      2      3                    |
|     0                                                        |
|                                                              |
|o9 : Complex                                                  |
+--------------------------------------------------------------+
|i10 : C4_[first] -- inclusion map C1 --> C4                   |
|                                                              |
|                                            1                 |
|o10 = 0 : image | 1 0 0 0 | <------------- S  : 0             |
|                | 0 a b c |    {0} | 1 |                      |
|                               {1} | 0 |                      |
|                               {1} | 0 |                      |
|                               {1} | 0 |                      |
|                                                              |
|           3                     3                            |
|      1 : S  <----------------- S  : 1                        |
|                {1} | 1 0 0 |                                 |
|                {1} | 0 1 0 |                                 |
|                {1} | 0 0 1 |                                 |
|                                                              |
|           3                     3                            |
|      2 : S  <----------------- S  : 2                        |
|                {2} | 1 0 0 |                                 |
|                {2} | 0 1 0 |                                 |
|                {2} | 0 0 1 |                                 |
|                                                              |
|           1                 1                                |
|      3 : S  <------------- S  : 3                            |
|                {3} | 1 |                                     |
|                                                              |
|o10 : ComplexMap                                              |
+--------------------------------------------------------------+
|i11 : C4^[first] -- projection map C4 --> C1                  |
|                                                              |
|           1                                                  |
|o11 = 0 : S  <--------------- image | 1 0 0 0 | : 0           |
|                | 1 0 0 0 |         | 0 a b c |               |
|                                                              |
|           3                     3                            |
|      1 : S  <----------------- S  : 1                        |
|                {1} | 1 0 0 |                                 |
|                {1} | 0 1 0 |                                 |
|                {1} | 0 0 1 |                                 |
|                                                              |
|           3                     3                            |
|      2 : S  <----------------- S  : 2                        |
|                {2} | 1 0 0 |                                 |
|                {2} | 0 1 0 |                                 |
|                {2} | 0 0 1 |                                 |
|                                                              |
|           1                 1                                |
|      3 : S  <------------- S  : 3                            |
|                {3} | 1 |                                     |
|                                                              |
|o11 : ComplexMap                                              |
+--------------------------------------------------------------+
|i12 : C4^[first] * C4_[first] == 1                            |
|                                                              |
|o12 = true                                                    |
+--------------------------------------------------------------+
|i13 : C4^[second] * C4_[second] == 1                          |
|                                                              |
|o13 = true                                                    |
+--------------------------------------------------------------+
|i14 : C4^[first] * C4_[second] == 0                           |
|                                                              |
|o14 = true                                                    |
+--------------------------------------------------------------+
|i15 : C4^[second] * C4_[first] == 0                           |
|                                                              |
|o15 = true                                                    |
+--------------------------------------------------------------+
|i16 : C4_[first] * C4^[first] + C4_[second] * C4^[second] == 1|
|                                                              |
|o16 = true                                                    |
+--------------------------------------------------------------+

There are two short exact sequences associated to a direct sum.

+---------------------------------------------------+
|i17 : isShortExactSequence(C4^[first], C4_[second])|
|                                                   |
|o17 = true                                         |
+---------------------------------------------------+
|i18 : isShortExactSequence(C4^[second], C4_[first])|
|                                                   |
|o18 = true                                         |
+---------------------------------------------------+

Given a complex which is a direct sum, we obtain the component complexes and
their names (indices) as follows.

+-----------------------------------------------------------------+
|i19 : components C3                                              |
|                                                                 |
|        1      3      3      1                                   |
|o19 = {S  <-- S  <-- S  <-- S , image | a b c |, image | a b c |}|
|                                                                 |
|       0      1      2      3   0                2               |
|                                                                 |
|o19 : List                                                       |
+-----------------------------------------------------------------+
|i20 : indices C3                                                 |
|                                                                 |
|o20 = {0, 1, 2}                                                  |
|                                                                 |
|o20 : List                                                       |
+-----------------------------------------------------------------+
|i21 : components C4                                              |
|                                                                 |
|        1      3      3      1                                   |
|o21 = {S  <-- S  <-- S  <-- S , image | a b c |}                 |
|                                                                 |
|       0      1      2      3   0                                |
|                                                                 |
|o21 : List                                                       |
+-----------------------------------------------------------------+
|i22 : indices C4                                                 |
|                                                                 |
|o22 = {first, second}                                            |
|                                                                 |
|o22 : List                                                       |
+-----------------------------------------------------------------+

See also
========

  * components(Complex) -- list the components
    of a direct sum
  * indices (Macaulay2Doc) -- indices of a polynomial; also
    components for a direct sum
  * Complex ^ Array -- the canonical inclusion or
    projection map of a direct sum
  * Complex _ Array -- the canonical inclusion or
    projection map of a direct sum
  * isShortExactSequence(ComplexMap,ComplexMap)
    -- whether a pair of
    complex maps forms a short exact sequence
  * sum(Complex) -- make the direct sum of all terms

Ways to use this method:
========================

  * directSum(Complex) -- direct sum of
    complexes

dual(Complex) -- make the dual of a complex
*******************************************

Synopsis
========

  * Function: dual (Macaulay2Doc),
  * Usage:
        dual C
  * Inputs:
      * C, a complex,
  * Outputs:
      * a complex,

Description
===========

The dual of a complex $C$ is by definition $Hom(C, R)$, where $R$ is the ring
of $C$.

+------------------------------------------------------------+
|i1 : S = ZZ/101[a..d];                                      |
+------------------------------------------------------------+
|i2 : B = intersect(ideal(a,c),ideal(b,d))                   |
|                                                            |
|o2 = ideal (c*d, a*d, b*c, a*b)                             |
|                                                            |
|o2 : Ideal of S                                             |
+------------------------------------------------------------+
|i3 : C1 = freeResolution B                                  |
|                                                            |
|      1      4      4      1                                |
|o3 = S  <-- S  <-- S  <-- S                                 |
|                                                            |
|     0      1      2      3                                 |
|                                                            |
|o3 : Complex                                                |
+------------------------------------------------------------+
|i4 : C2 = dual C1                                           |
|                                                            |
|      1      4      4      1                                |
|o4 = S  <-- S  <-- S  <-- S                                 |
|                                                            |
|     -3     -2     -1     0                                 |
|                                                            |
|o4 : Complex                                                |
+------------------------------------------------------------+
|i5 : assert(C2 == Hom(C1, S^1))                             |
+------------------------------------------------------------+
|i6 : C1 == dual dual C1                                     |
|                                                            |
|o6 = true                                                   |
+------------------------------------------------------------+
|i7 : prune HH C2                                            |
|                                                            |
|o7 = cokernel {-4} | d c b a | <-- cokernel {-2} | c a 0 0 ||
|                                            {-2} | 0 0 d b ||
|     -3                                                     |
|                                   -2                       |
|                                                            |
|o7 : Complex                                                |
+------------------------------------------------------------+

The double dual is not necessarily isomorphic to the original complex.

+-----------------------------------------------------------------------------+
|i8 : I = ideal(a^2, a*b, b^2)                                                |
|                                                                             |
|             2        2                                                      |
|o8 = ideal (a , a*b, b )                                                     |
|                                                                             |
|o8 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i9 : J = ideal(b^3, b*c, c^3)                                                |
|                                                                             |
|             3        3                                                      |
|o9 = ideal (b , b*c, c )                                                     |
|                                                                             |
|o9 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i10 : K = intersect(I,J)                                                     |
|                                                                             |
|              2           3   2 3                                            |
|o10 = ideal (b c, a*b*c, b , a c )                                           |
|                                                                             |
|o10 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i11 : f = map(S^1/I ++ S^1/J, S^1/K, {{1},{1}})                              |
|                                                                             |
|o11 = | 1 |                                                                  |
|      | 1 |                                                                  |
|                                                                             |
|o11 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i12 : g = map(S^1/(I+J), S^1/I ++ S^1/J, {{1,-1}})                           |
|                                                                             |
|o12 = | 1 -1 |                                                               |
|                                                                             |
|o12 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i13 : C = complex{g,f}                                                       |
|                                                                             |
|o13 = cokernel | a2 ab b2 b3 bc c3 | <-- cokernel | a2 ab b2 0  0  0  | <--  |
|                                                  | 0  0  0  b3 bc c3 |      |
|      0                                                                      |
|                                         1                                   |
|                                                                             |
|o13 : Complex                                                                |
|-----------------------------------------------------------------------------|
|cokernel | b2c abc b3 a2c3 |                                                 |
|                                                                             |
|2                                                                            |
+-----------------------------------------------------------------------------+
|i14 : assert isWellDefined C                                                 |
+-----------------------------------------------------------------------------+
|i15 : assert isExact C                                                       |
+-----------------------------------------------------------------------------+
|i16 : assert(dual C == 0)                                                    |
+-----------------------------------------------------------------------------+
|i17 : assert(C != dual dual C)                                               |
+-----------------------------------------------------------------------------+

See also
========

  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes
  * dual(Module) (Macaulay2Doc) -- dual module

Ways to use this method:
========================

  * dual(Complex) -- make the dual of a complex

dual(ComplexMap) -- the dual of a map of complexes
**************************************************

Synopsis
========

  * Function: dual (Macaulay2Doc),
  * Usage:
        h = dual f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * h, a map of complexes,

Description
===========

The map $f : C \to D$ of chain complexes over the ring $S$ induces the map $h =
Hom(f, S^1) : Hom(D, S^1) \to Hom(C,S^1)$ defined by $\phi \mapsto \phi f$.

+----------------------------------------------------------------+
|i1 : S = ZZ/101[a..c]                                           |
|                                                                |
|o1 = S                                                          |
|                                                                |
|o1 : PolynomialRing                                             |
+----------------------------------------------------------------+
|i2 : C = freeResolution coker vars S                            |
|                                                                |
|      1      3      3      1                                    |
|o2 = S  <-- S  <-- S  <-- S                                     |
|                                                                |
|     0      1      2      3                                     |
|                                                                |
|o2 : Complex                                                    |
+----------------------------------------------------------------+
|i3 : D = (freeResolution coker matrix{{a^2,a*b,b^3}})[-1]       |
|                                                                |
|      1      3      2                                           |
|o3 = S  <-- S  <-- S                                            |
|                                                                |
|     1      2      3                                            |
|                                                                |
|o3 : Complex                                                    |
+----------------------------------------------------------------+
|i4 : f = randomComplexMap(D,C)                                  |
|                                                                |
|                   1                                            |
|o4 = 0 : 0 <----- S  : 0                                        |
|              0                                                 |
|                                                                |
|          1                                                3    |
|     1 : S  <-------------------------------------------- S  : 1|
|               | 24a-36b-30c -29a+19b+19c -10a-29b-8c |         |
|                                                                |
|          3                           3                         |
|     2 : S  <----------------------- S  : 2                     |
|               {2} | -22 -24 -16 |                              |
|               {2} | -29 -38 39  |                              |
|               {3} | 0   0   0   |                              |
|                                                                |
|          2                  1                                  |
|     3 : S  <-------------- S  : 3                              |
|               {3} | 21 |                                       |
|               {4} | 0  |                                       |
|                                                                |
|o4 : ComplexMap                                                 |
+----------------------------------------------------------------+
|i5 : h = dual f                                                 |
|                                                                |
|           1                     2                              |
|o5 = -3 : S  <----------------- S  : -3                         |
|                {-3} | 21 0 |                                   |
|                                                                |
|           3                          3                         |
|     -2 : S  <---------------------- S  : -2                    |
|                {-2} | -22 -29 0 |                              |
|                {-2} | -24 -38 0 |                              |
|                {-2} | -16 39  0 |                              |
|                                                                |
|           3                             1                      |
|     -1 : S  <------------------------- S  : -1                 |
|                {-1} | 24a-36b-30c  |                           |
|                {-1} | -29a+19b+19c |                           |
|                {-1} | -10a-29b-8c  |                           |
|                                                                |
|o5 : ComplexMap                                                 |
+----------------------------------------------------------------+
|i6 : assert isWellDefined h                                     |
+----------------------------------------------------------------+
|i7 : assert(h == Hom(f, S^1))                                   |
+----------------------------------------------------------------+
|i8 : assert(source h == Hom(D,S^1))                             |
+----------------------------------------------------------------+
|i9 : assert(target h == Hom(C,S^1))                             |
+----------------------------------------------------------------+

This routine is functorial.

+-----------------------------------------------------------+
|i10 : D' = (freeResolution coker matrix{{a^2,a*b,c^3}})[-1]|
|                                                           |
|       1      3      3      1                              |
|o10 = S  <-- S  <-- S  <-- S                               |
|                                                           |
|      1      2      3      4                               |
|                                                           |
|o10 : Complex                                              |
+-----------------------------------------------------------+
|i11 : f' = randomComplexMap(D', D)                         |
|                                                           |
|           1              1                                |
|o11 = 1 : S  <---------- S  : 1                            |
|                | 34 |                                     |
|                                                           |
|           3                                    3          |
|      2 : S  <-------------------------------- S  : 2      |
|                {2} | 19  -39 -13a-43b-15c |               |
|                {2} | -47 -18 -28a-47b+38c |               |
|                {3} | 0   0   2            |               |
|                                                           |
|           3                              2                |
|      3 : S  <-------------------------- S  : 3            |
|                {3} | 16 22a+45b-34c |                     |
|                {5} | 0  0           |                     |
|                {5} | 0  0           |                     |
|                                                           |
|o11 : ComplexMap                                           |
+-----------------------------------------------------------+
|i12 : dual(f' * f) == dual f * dual f'                     |
|                                                           |
|o12 = true                                                 |
+-----------------------------------------------------------+

See also
========

  * Hom(ComplexMap,ComplexMap) -- the
    map of complexes between Hom complexes
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes
  * dual(Matrix) (Macaulay2Doc) -- dual of a map

Ways to use this method:
========================

  * dual(ComplexMap) -- the dual of a map of
    complexes

extend(Complex,Complex,Matrix,Sequence) -- extend a map of modules to a map of chain complexes
**********************************************************************************************

Synopsis
========

  * Function: extend (Macaulay2Doc),
  * Usage:
        g = extend(D, C, f, p)
        g = extend(D, C, f)
  * Inputs:
      * C, a complex,
      * D, a complex,
      * f, a matrix (Macaulay2Doc),
      * p, a sequence (Macaulay2Doc), consisting of a pair of
        integers $(j,i)$, such that the matrix $f$ defines a map from $C_i$ to
        $D_j$; the default value is $i = j = 0$
  * Optional inputs (Macaulay2Doc),:
      * Verify (Macaulay2Doc),
        => a Boolean value (Macaulay2Doc), default
        value true, currently, this option is ignored
  * Outputs:
      * a map of complexes,

Description
===========

Let $C$ be a chain complex such that each term is a free module.  Let $D$ be a
chain complex which is exact at the $k$-th term for all $k > j$. Given a map of
modules $f \colon C_i \to D_j$ such that the image of $f \circ
\operatorname{dd}^C_{i+1}$ is contained in the image of
$\operatorname{dd}^D_{j+1}$, this method constructs a morphism of chain
complexes $g \colon C \to D$ of degree $j-i$ such that $g_i = f$.

$\phantom{WWWW} \begin{array}{cccccc} 0 & \!\!\leftarrow\!\! & C_{i} &
\!\!\leftarrow\!\! & C_{i+1} & \!\!\leftarrow\!\! & C_{i+2} & \dotsb \\ &
& \downarrow \, {\scriptstyle f} & & \downarrow \, {\scriptstyle g_{i+1}} &&
\downarrow \, {\scriptstyle g_{i+2}} \\ 0 & \!\!\leftarrow\!\! & D_{j} &
\!\!\leftarrow\!\! & D_{j+1} &  \!\!\leftarrow\!\! & D_{j+2} & \dotsb \\
\end{array} $

A map between modules extends to a map between their free resolutions.

+---------------------------------------------+
|i1 : S = ZZ/101[a..d];                       |
+---------------------------------------------+
|i2 : I = ideal(a*b*c, b*c*d, a*d^2)          |
|                                             |
|                             2               |
|o2 = ideal (a*b*c, b*c*d, a*d )              |
|                                             |
|o2 : Ideal of S                              |
+---------------------------------------------+
|i3 : C = S^{{-3}} ** freeResolution (I:a*c*d)|
|                                             |
|      1      2      1                        |
|o3 = S  <-- S  <-- S                         |
|                                             |
|     0      1      2                         |
|                                             |
|o3 : Complex                                 |
+---------------------------------------------+
|i4 : D = freeResolution I                    |
|                                             |
|      1      3      2                        |
|o4 = S  <-- S  <-- S                         |
|                                             |
|     0      1      2                         |
|                                             |
|o4 : Complex                                 |
+---------------------------------------------+
|i5 : f = map(D_0, C_0, matrix{{a*c*d}})      |
|                                             |
|o5 = | acd |                                 |
|                                             |
|             1       1                       |
|o5 : Matrix S  <--- S                        |
+---------------------------------------------+
|i6 : g = extend(D, C, f)                     |
|                                             |
|          1               1                  |
|o6 = 0 : S  <----------- S  : 0              |
|               | acd |                       |
|                                             |
|          3                   2              |
|     1 : S  <--------------- S  : 1          |
|               {3} | 0 0 |                   |
|               {3} | a 0 |                   |
|               {3} | 0 c |                   |
|                                             |
|          2                 1                |
|     2 : S  <------------- S  : 2            |
|               {4} | 0 |                     |
|               {5} | 1 |                     |
|                                             |
|o6 : ComplexMap                              |
+---------------------------------------------+
|i7 : assert isWellDefined g                  |
+---------------------------------------------+
|i8 : assert isComplexMorphism g              |
+---------------------------------------------+
|i9 : assert(g_0 == f)                        |
+---------------------------------------------+
|i10 : E = cone g                             |
|                                             |
|       1      4      4      1                |
|o10 = S  <-- S  <-- S  <-- S                 |
|                                             |
|      0      1      2      3                 |
|                                             |
|o10 : Complex                                |
+---------------------------------------------+
|i11 : dd^E                                   |
|                                             |
|           1                           4     |
|o11 = 0 : S  <----------------------- S  : 1 |
|                | acd abc bcd ad2 |          |
|                                             |
|           4                            4    |
|      1 : S  <------------------------ S  : 2|
|                {3} | -b -d 0  0   |         |
|                {3} | 0  0  -d 0   |         |
|                {3} | a  0  a  -ad |         |
|                {3} | 0  c  0  bc  |         |
|                                             |
|           4                  1              |
|      2 : S  <-------------- S  : 3          |
|                {4} | d  |                   |
|                {4} | -b |                   |
|                {4} | 0  |                   |
|                {5} | 1  |                   |
|                                             |
|o11 : ComplexMap                             |
+---------------------------------------------+

Extension of maps to complexes is also useful in constructing a free resolution
of a linked ideal.

+-----------------------------------------------------------------------------+
|i12 : I = monomialCurveIdeal(S, {1,2,3})                                     |
|                                                                             |
|              2                    2                                         |
|o12 = ideal (c  - b*d, b*c - a*d, b  - a*c)                                  |
|                                                                             |
|o12 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i13 : K = ideal(I_1^2, I_2^2)                                                |
|                                                                             |
|              2 2               2 2   4       2     2 2                      |
|o13 = ideal (b c  - 2a*b*c*d + a d , b  - 2a*b c + a c )                     |
|                                                                             |
|o13 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i14 : FI = freeResolution I                                                  |
|                                                                             |
|       1      3      2                                                       |
|o14 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o14 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i15 : FK = freeResolution K                                                  |
|                                                                             |
|       1      2      1                                                       |
|o15 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o15 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i16 : f = map(FI_0, FK_0, 1)                                                 |
|                                                                             |
|o16 = | 1 |                                                                  |
|                                                                             |
|              1       1                                                      |
|o16 : Matrix S  <--- S                                                       |
+-----------------------------------------------------------------------------+
|i17 : g = extend(FI, FK, f)                                                  |
|                                                                             |
|           1             1                                                   |
|o17 = 0 : S  <--------- S  : 0                                               |
|                | 1 |                                                        |
|                                                                             |
|           3                         2                                       |
|      1 : S  <--------------------- S  : 1                                   |
|                {2} | b2-ac c2  |                                            |
|                {2} | 0     -ad |                                            |
|                {2} | 0     ac  |                                            |
|                                                                             |
|           2                                      1                          |
|      2 : S  <---------------------------------- S  : 2                      |
|                {3} | -ab2c2+a2c3+ab3d-a2bcd |                               |
|                {3} | -ab3c+a2bc2+a2b2d-a3cd |                               |
|                                                                             |
|o17 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i18 : assert isWellDefined g                                                 |
+-----------------------------------------------------------------------------+
|i19 : assert isComplexMorphism g                                             |
+-----------------------------------------------------------------------------+
|i20 : assert(g_0 == f)                                                       |
+-----------------------------------------------------------------------------+
|i21 : C = cone (dual g)[- codim K]                                           |
|                                                                             |
|       1      4      4      1                                                |
|o21 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o21 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i22 : dd^C                                                                   |
|                                                                             |
|           1                                                                 |
|o22 = 0 : S  <---------------------------------------------------------------|
|                {-8} | -ab2c2+a2c3+ab3d-a2bcd -ab3c+a2bc2+a2b2d-a3cd b2c2-2ab|
|                                                                             |
|           4                                             4                   |
|      1 : S  <----------------------------------------- S  : 2               |
|                {-3} | c     -b  a  0               |                        |
|                {-3} | -d    c   -b 0               |                        |
|                {-4} | b2-ac 0   0  b4-2ab2c+a2c2   |                        |
|                {-4} | c2    -ad ac b2c2-2abcd+a2d2 |                        |
|                                                                             |
|           4                       1                                         |
|      2 : S  <------------------- S  : 3                                     |
|                {-2} | -b2+ac |                                              |
|                {-2} | -bc+ad |                                              |
|                {-2} | -c2+bd |                                              |
|                {0}  | 1      |                                              |
|                                                                             |
|o22 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                            4                                                |
|-------------------------- S  : 1                                            |
|cd+a2d2 -b4+2ab2c-a2c2 |                                                     |
+-----------------------------------------------------------------------------+
|i23 : dd^(minimize C)                                                        |
|                                                                             |
|           1                                                                 |
|o23 = 0 : S  <---------------------------------------------------------------|
|                {-8} | -ab2c2+a2c3+ab3d-a2bcd -ab3c+a2bc2+a2b2d-a3cd b2c2-2ab|
|                                                                             |
|           4                             3                                   |
|      1 : S  <------------------------- S  : 2                               |
|                {-3} | c     -b  a  |                                        |
|                {-3} | -d    c   -b |                                        |
|                {-4} | b2-ac 0   0  |                                        |
|                {-4} | c2    -ad ac |                                        |
|                                                                             |
|o23 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                            4                                                |
|-------------------------- S  : 1                                            |
|cd+a2d2 -b4+2ab2c-a2c2 |                                                     |
+-----------------------------------------------------------------------------+
|i24 : assert(ideal relations HH_0 C == K:I)                                  |
+-----------------------------------------------------------------------------+

Inspired by a yonedaMap, computation, we extend a
map of modules to a map between free resolutions having homological degree
$-1$.

+-----------------------------------------------------------------------------+
|i25 : f = map(FK_0, FI_1, matrix {{a*c^2-a*b*d, -b*c^2+a*c*d, -c^3+a*d^2}},  |
|                                                                             |
|o25 = | ac2-abd -bc2+acd -c3+ad2 |                                           |
|                                                                             |
|              1       3                                                      |
|o25 : Matrix S  <--- S                                                       |
|-----------------------------------------------------------------------------|
|Degree => 1)                                                                 |
+-----------------------------------------------------------------------------+
|i26 : assert isHomogeneous f                                                 |
+-----------------------------------------------------------------------------+
|i27 : assert isWellDefined f                                                 |
+-----------------------------------------------------------------------------+
|i28 : g = extend(FK, FI, f, (0,1))                                           |
|                                                                             |
|           1                                    3                            |
|o28 = 0 : S  <-------------------------------- S  : 1                        |
|                | ac2-abd -bc2+acd -c3+ad2 |                                 |
|                                                                             |
|           2                   2                                             |
|      1 : S  <--------------- S  : 2                                         |
|                {4} | 0 0 |                                                  |
|                {4} | 1 0 |                                                  |
|                                                                             |
|o28 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i29 : assert isWellDefined g                                                 |
+-----------------------------------------------------------------------------+
|i30 : assert isCommutative g                                                 |
+-----------------------------------------------------------------------------+
|i31 : assert(degree g === -1)                                                |
+-----------------------------------------------------------------------------+
|i32 : assert isHomogeneous g                                                 |
+-----------------------------------------------------------------------------+

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * cone(ComplexMap) -- make the mapping cone of a
    morphism of chain complexes
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes
  * minimize(Complex) -- a quasi-isomorphic
    complex whose terms have minimal rank

Ways to use this method:
========================

  * "extend(Complex,Complex,Matrix)"
  * extend(Complex,Complex,Matrix,Sequence)
    -- extend a map of
    modules to a map of chain complexes

freeResolution -- compute a free resolution of a module or ideal
****************************************************************

Synopsis
========

  * Usage:
        freeResolution M
  * Inputs:
      * M, a module (Macaulay2Doc), or an ideal (Macaulay2Doc),
        or a monomial ideal (Macaulay2Doc),
        an ideal I in a ring R
  * Optional inputs (Macaulay2Doc),:
      * LengthLimit => an integer (Macaulay2Doc), default value
        infinity, this is used to limit somehow the computation where
        resolutions might be too long or infinite
      * DegreeLimit => a list (Macaulay2Doc), default value
        infinity, or an integer (Macaulay2Doc), an option that
        specifies that the computation stops at the given (slanted) degree
      * FastNonminimal => a Boolean value (Macaulay2Doc),
        default value false, unused (TODO: probably used)
      * HardDegreeLimit => a list (Macaulay2Doc), default value {},
        unused (TODO: used?)
      * PairLimit => an integer (Macaulay2Doc), default value
        infinity, or infinity (Macaulay2Doc), an internal
        option which specifies that the computation should stop after a certain
        number of s-pairs have computed
      * SortStrategy => an integer (Macaulay2Doc), default value 0,
        an internal option that specifies the strategy to be used for sorting
        S-pairs
      * StopBeforeComputation => a Boolean value (Macaulay2Doc),
        default value false, whether to start the computation. This can be
        useful when you want to obtain the partially computed resolution
        contained in an interrupted computation.
      * Strategy => an integer (Macaulay2Doc), default value null,
        TODO: perhaps needs its own page
      * SyzygyLimit => an integer (Macaulay2Doc), default value
        infinity, or infinity (Macaulay2Doc), an internal
        option which specifies that the computation should stop after a certain
        number of syzygies have computed
  * Outputs:
      * a complex, a free resolution of the module M or of the
        quotient module R^1/I

Description
===========

A free resolution of a module $M$ is a complex $ F_0 \leftarrow F_1 \leftarrow
F_2 \leftarrow \ldots$ of free modules, which is acyclic: the cokernel of the
map to $F_0$ is $M$ and the complex is exact at all other locations.

+---------------------------------------------+
|i1 : R = QQ[a..d]                            |
|                                             |
|o1 = R                                       |
|                                             |
|o1 : PolynomialRing                          |
+---------------------------------------------+
|i2 : I = ideal(c^2-b*d, b*c-a*d, b^2-a*c)    |
|                                             |
|             2                    2          |
|o2 = ideal (c  - b*d, b*c - a*d, b  - a*c)   |
|                                             |
|o2 : Ideal of R                              |
+---------------------------------------------+
|i3 : M = R^1/I                               |
|                                             |
|o3 = cokernel | c2-bd bc-ad b2-ac |          |
|                                             |
|                            1                |
|o3 : R-module, quotient of R                 |
+---------------------------------------------+
|i4 : C = freeResolution M                    |
|                                             |
|      1      3      2                        |
|o4 = R  <-- R  <-- R                         |
|                                             |
|     0      1      2                         |
|                                             |
|o4 : Complex                                 |
+---------------------------------------------+
|i5 : betti C                                 |
|                                             |
|            0 1 2                            |
|o5 = total: 1 3 2                            |
|         0: 1 . .                            |
|         1: . 3 2                            |
|                                             |
|o5 : BettiTally                              |
+---------------------------------------------+
|i6 : length C                                |
|                                             |
|o6 = 2                                       |
+---------------------------------------------+
|i7 : dd^C                                    |
|                                             |
|          1                             3    |
|o7 = 0 : R  <------------------------- R  : 1|
|               | b2-ac bc-ad c2-bd |         |
|                                             |
|          3                     2            |
|     1 : R  <----------------- R  : 2        |
|               {2} | -c d  |                 |
|               {2} | b  -c |                 |
|               {2} | -a b  |                 |
|                                             |
|o7 : ComplexMap                              |
+---------------------------------------------+
|i8 : assert isWellDefined C                  |
+---------------------------------------------+
|i9 : assert(prune HH C == complex M)         |
+---------------------------------------------+

Giving an ideal as the input produces a free resolution not of the module I,
but of the module R^1/I.

+----------------------------------------------+
|i10 : assert(freeResolution I == C)           |
+----------------------------------------------+
|i11 : resolution complex M == freeResolution M|
|                                              |
|o11 = true                                    |
+----------------------------------------------+

Over a quotient ring, free resolutions are often infinite. Use the optional
argument LengthLimit to obtain part of the resolution.

+---------------------------------------------------------+
|i12 : S = ZZ/101[a,b]                                    |
|                                                         |
|o12 = S                                                  |
|                                                         |
|o12 : PolynomialRing                                     |
+---------------------------------------------------------+
|i13 : R = S/(a^3+b^3)                                    |
|                                                         |
|o13 = R                                                  |
|                                                         |
|o13 : QuotientRing                                       |
+---------------------------------------------------------+
|i14 : C = freeResolution (coker vars R, LengthLimit => 7)|
|                                                         |
|       1      2      2      2      2      2      2      2|
|o14 = R  <-- R  <-- R  <-- R  <-- R  <-- R  <-- R  <-- R |
|                                                         |
|      0      1      2      3      4      5      6      7 |
|                                                         |
|o14 : Complex                                            |
+---------------------------------------------------------+
|i15 : dd^C                                               |
|                                                         |
|           1               2                             |
|o15 = 0 : R  <----------- R  : 1                         |
|                | a b |                                  |
|                                                         |
|           2                     2                       |
|      1 : R  <----------------- R  : 2                   |
|                {1} | -b a2 |                            |
|                {1} | a  b2 |                            |
|                                                         |
|           2                      2                      |
|      2 : R  <------------------ R  : 3                  |
|                {2} | a2 -b2 |                           |
|                {3} | b  a   |                           |
|                                                         |
|           2                     2                       |
|      3 : R  <----------------- R  : 4                   |
|                {4} | -a b2 |                            |
|                {4} | b  a2 |                            |
|                                                         |
|           2                      2                      |
|      4 : R  <------------------ R  : 5                  |
|                {5} | -a2 b2 |                           |
|                {6} | b   a  |                           |
|                                                         |
|           2                     2                       |
|      5 : R  <----------------- R  : 6                   |
|                {7} | -a b2 |                            |
|                {7} | b  a2 |                            |
|                                                         |
|           2                      2                      |
|      6 : R  <------------------ R  : 7                  |
|                {8} | -a2 b2 |                           |
|                {9} | b   a  |                           |
|                                                         |
|o15 : ComplexMap                                         |
+---------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * resolution(Complex) -- minimal free
    resolution of a complex
  * resolutionMap(Complex) -- map from a free resolution
    to the given complex
  * betti(Complex) -- display of degrees in a
    complex

Ways to use freeResolution :
============================

  * "freeResolution(Ideal)"
  * "freeResolution(Module)"
  * "freeResolution(MonomialIdeal)"
  * freeResolution(Matrix) -- compute the
    induced map between free resolutions

For the programmer
==================

The object freeResolution, is a method function with options (Macaulay2Doc).

freeResolution(Matrix) -- compute the induced map between free resolutions
**************************************************************************

Synopsis
========

  * Function: freeResolution,
  * Usage:
        freeResolution f
  * Inputs:
      * f, a matrix (Macaulay2Doc), defining a map from an
        $R$-module $M$ to an $R$-module $N$
  * Optional inputs (Macaulay2Doc),:
      * LengthLimit, => an integer (Macaulay2Doc),
        default value infinity, this is used to limit
        somehow the computation where resolutions might be too long or infinite
      * DegreeLimit, => a list (Macaulay2Doc),
        default value infinity, or an integer (Macaulay2Doc),
        an option that specifies that the computation stops
        at the given (slanted) degree
      * FastNonminimal, => a Boolean value (Macaulay2Doc),
        default value false, unused (TODO: probably
        used)
      * HardDegreeLimit, => a list (Macaulay2Doc),
        default value {}, unused (TODO: used?)
      * PairLimit, => an integer (Macaulay2Doc),
        default value infinity, or infinity (Macaulay2Doc),
        an internal option which specifies that the
        computation should stop after a certain number of s-pairs have computed
      * SortStrategy, => an integer (Macaulay2Doc),
        default value 0, an internal option that specifies
        the strategy to be used for sorting S-pairs
      * StopBeforeComputation, => a Boolean value (Macaulay2Doc),
        default value false, whether to start the
        computation. This can be useful when you want to obtain the partially
        computed resolution contained in an interrupted computation.
      * Strategy, => an integer (Macaulay2Doc),
        default value null, TODO: perhaps needs its own page
      * SyzygyLimit, => an integer (Macaulay2Doc),
        default value infinity, or infinity (Macaulay2Doc),
        an internal option which specifies that the
        computation should stop after a certain number of syzygies have
        computed
  * Outputs:
      * a map of complexes, an induced map of chain
        complexes from the free resolution of $M$ to the free resolution of $N$

Description
===========

A homomorphism $f \colon M \to N$ of $R$-modules induces a morphism of chain
complexes from any free resolution of $M$ to a free resolution of $N$.  This
method constructs this map of chain complexes.

+-------------------------------------------+
|i1 : R = QQ[a..d];                         |
+-------------------------------------------+
|i2 : I = ideal(c^2-b*d, b*c-a*d, b^2-a*c)  |
|                                           |
|             2                    2        |
|o2 = ideal (c  - b*d, b*c - a*d, b  - a*c) |
|                                           |
|o2 : Ideal of R                            |
+-------------------------------------------+
|i3 : J = ideal(I_0, I_1)                   |
|                                           |
|             2                             |
|o3 = ideal (c  - b*d, b*c - a*d)           |
|                                           |
|o3 : Ideal of R                            |
+-------------------------------------------+
|i4 : M = R^1/J                             |
|                                           |
|o4 = cokernel | c2-bd bc-ad |              |
|                                           |
|                            1              |
|o4 : R-module, quotient of R               |
+-------------------------------------------+
|i5 : N = R^1/I                             |
|                                           |
|o5 = cokernel | c2-bd bc-ad b2-ac |        |
|                                           |
|                            1              |
|o5 : R-module, quotient of R               |
+-------------------------------------------+
|i6 : f = map(N, M, 1)                      |
|                                           |
|o6 = | 1 |                                 |
|                                           |
|o6 : Matrix                                |
+-------------------------------------------+
|i7 : g = freeResolution f                  |
|                                           |
|          1             1                  |
|o7 = 0 : R  <--------- R  : 0              |
|               | 1 |                       |
|                                           |
|          3                   2            |
|     1 : R  <--------------- R  : 1        |
|               {2} | 0 0 |                 |
|               {2} | 1 0 |                 |
|               {2} | 0 1 |                 |
|                                           |
|          2                  1             |
|     2 : R  <-------------- R  : 2         |
|               {3} | -d |                  |
|               {3} | -c |                  |
|                                           |
|o7 : ComplexMap                            |
+-------------------------------------------+
|i8 : assert isWellDefined g                |
+-------------------------------------------+
|i9 : assert isComplexMorphism g            |
+-------------------------------------------+
|i10 : assert(source g === freeResolution M)|
+-------------------------------------------+
|i11 : assert(target g === freeResolution N)|
+-------------------------------------------+

Taking free resolutions is a functor, up to homotopy, from the category of
modules to the category of chain complexes. In the subsequent example, the
composition of the induced chain maps $g$ and $g'$ happens to be equal to the
induced map of the composition.

+-----------------------------------------------------------+
|i12 : K = ideal(I_0)                                       |
|                                                           |
|             2                                             |
|o12 = ideal(c  - b*d)                                      |
|                                                           |
|o12 : Ideal of R                                           |
+-----------------------------------------------------------+
|i13 : L = R^1/K                                            |
|                                                           |
|o13 = cokernel | c2-bd |                                   |
|                                                           |
|                             1                             |
|o13 : R-module, quotient of R                              |
+-----------------------------------------------------------+
|i14 : f' = map(M, L, 1)                                    |
|                                                           |
|o14 = | 1 |                                                |
|                                                           |
|o14 : Matrix                                               |
+-----------------------------------------------------------+
|i15 : g' = freeResolution f'                               |
|                                                           |
|           1             1                                 |
|o15 = 0 : R  <--------- R  : 0                             |
|                | 1 |                                      |
|                                                           |
|           2                 1                             |
|      1 : R  <------------- R  : 1                         |
|                {2} | 0 |                                  |
|                {2} | 1 |                                  |
|                                                           |
|o15 : ComplexMap                                           |
+-----------------------------------------------------------+
|i16 : g'' = freeResolution(f * f')                         |
|                                                           |
|           1             1                                 |
|o16 = 0 : R  <--------- R  : 0                             |
|                | 1 |                                      |
|                                                           |
|           3                 1                             |
|      1 : R  <------------- R  : 1                         |
|                {2} | 0 |                                  |
|                {2} | 0 |                                  |
|                {2} | 1 |                                  |
|                                                           |
|o16 : ComplexMap                                           |
+-----------------------------------------------------------+
|i17 : assert(g'' === g * g')                               |
+-----------------------------------------------------------+
|i18 : assert(freeResolution id_N === id_(freeResolution N))|
+-----------------------------------------------------------+

Over a quotient ring, free resolutions are often infinite. Use the optional
argument LengthLimit to obtain a truncation of the map between resolutions.

+---------------------------------------------+
|i19 : S = ZZ/101[a,b]                        |
|                                             |
|o19 = S                                      |
|                                             |
|o19 : PolynomialRing                         |
+---------------------------------------------+
|i20 : R = S/(a^3+b^3)                        |
|                                             |
|o20 = R                                      |
|                                             |
|o20 : QuotientRing                           |
+---------------------------------------------+
|i21 : f = map(R^1/(a,b), R^1/(a^2, b^2), 1)  |
|                                             |
|o21 = | 1 |                                  |
|                                             |
|o21 : Matrix                                 |
+---------------------------------------------+
|i22 : g = freeResolution(f, LengthLimit => 7)|
|                                             |
|           1             1                   |
|o22 = 0 : R  <--------- R  : 0               |
|                | 1 |                        |
|                                             |
|           2                   2             |
|      1 : R  <--------------- R  : 1         |
|                {1} | a 0 |                  |
|                {1} | 0 b |                  |
|                                             |
|           2                    2            |
|      2 : R  <---------------- R  : 2        |
|                {2} | 0 ab |                 |
|                {3} | 1 0  |                 |
|                                             |
|           2                   2             |
|      3 : R  <--------------- R  : 3         |
|                {4} | 0 b |                  |
|                {4} | a 0 |                  |
|                                             |
|           2                     2           |
|      4 : R  <----------------- R  : 4       |
|                {5} | 0 -ab |                |
|                {6} | 1 0   |                |
|                                             |
|           2                   2             |
|      5 : R  <--------------- R  : 5         |
|                {7} | 0 b |                  |
|                {7} | a 0 |                  |
|                                             |
|           2                     2           |
|      6 : R  <----------------- R  : 6       |
|                {8} | 0 -ab |                |
|                {9} | 1 0   |                |
|                                             |
|           2                    2            |
|      7 : R  <---------------- R  : 7        |
|                {10} | 0 b |                 |
|                {10} | a 0 |                 |
|                                             |
|o22 : ComplexMap                             |
+---------------------------------------------+
|i23 : assert isWellDefined g                 |
+---------------------------------------------+
|i24 : assert isComplexMorphism g             |
+---------------------------------------------+

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * freeResolution(Module) -- compute a free resolution
    of a module or ideal
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes

Ways to use this method:
========================

  * freeResolution(Matrix) -- compute the
    induced map between free resolutions

gradedModule(Complex) -- a new complex in which the differential is zero
************************************************************************

Synopsis
========

  * Function: gradedModule (Macaulay2Doc),
  * Usage:
        gradedModule C
  * Inputs:
      * C, a complex,
  * Outputs:
      * a complex, whose differential is the zero map

Description
===========

This routine isolates the terms in the complex and forgets the differentials

+--------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c,d,e];                             |
+--------------------------------------------------------+
|i2 : I = intersect(ideal(a,b),ideal(c,d,e))             |
|                                                        |
|o2 = ideal (b*e, a*e, b*d, a*d, b*c, a*c)               |
|                                                        |
|o2 : Ideal of R                                         |
+--------------------------------------------------------+
|i3 : C = (dual freeResolution I)[-4]                    |
|                                                        |
|      1      5      9      6      1                     |
|o3 = R  <-- R  <-- R  <-- R  <-- R                      |
|                                                        |
|     0      1      2      3      4                      |
|                                                        |
|o3 : Complex                                            |
+--------------------------------------------------------+
|i4 : dd^C                                               |
|                                                        |
|          1                             5               |
|o4 = 0 : R  <------------------------- R  : 1           |
|               {-5} | -e d -c -b a |                    |
|                                                        |
|          5                                        9    |
|     1 : R  <------------------------------------ R  : 2|
|               {-4} | d -c -b a 0  0  0  0  0 |         |
|               {-4} | e 0  0  0 -c -b a  0  0 |         |
|               {-4} | 0 e  0  0 -d 0  0  -b a |         |
|               {-4} | 0 0  e  0 0  -d 0  c  0 |         |
|               {-4} | 0 0  0  e 0  0  -d 0  c |         |
|                                                        |
|          9                                 6           |
|     2 : R  <----------------------------- R  : 3       |
|               {-3} | -b a  0  0  0  0 |                |
|               {-3} | 0  0  -b a  0  0 |                |
|               {-3} | -d 0  c  0  0  0 |                |
|               {-3} | 0  -d 0  c  0  0 |                |
|               {-3} | 0  0  0  0  -b a |                |
|               {-3} | -e 0  0  0  c  0 |                |
|               {-3} | 0  -e 0  0  0  c |                |
|               {-3} | 0  0  -e 0  d  0 |                |
|               {-3} | 0  0  0  -e 0  d |                |
|                                                        |
|          6                   1                         |
|     3 : R  <--------------- R  : 4                     |
|               {-2} | ac |                              |
|               {-2} | bc |                              |
|               {-2} | ad |                              |
|               {-2} | bd |                              |
|               {-2} | ae |                              |
|               {-2} | be |                              |
|                                                        |
|o4 : ComplexMap                                         |
+--------------------------------------------------------+
|i5 : G = gradedModule C                                 |
|                                                        |
|      1      5      9      6      1                     |
|o5 = R  <-- R  <-- R  <-- R  <-- R                      |
|                                                        |
|     0      1      2      3      4                      |
|                                                        |
|o5 : Complex                                            |
+--------------------------------------------------------+
|i6 : dd^G                                               |
|                                                        |
|o6 = 0                                                  |
|                                                        |
|o6 : ComplexMap                                         |
+--------------------------------------------------------+
|i7 : assert(isWellDefined G)                            |
+--------------------------------------------------------+
|i8 : assert(G != C)                                     |
+--------------------------------------------------------+

The homology of a complex already has zero differential.

+-----------------------------------------------------------------------------+
|i9 : H = HH C                                                                |
|                                                                             |
|o9 = cokernel {-5} | -e d -c -b a | <-- subquotient ({-4} | d c  0 b  0 0  a |
|                                                     {-4} | e 0  c 0  b 0  0 |
|     0                                               {-4} | 0 -e d 0  0 b  0 |
|                                                     {-4} | 0 0  0 -e d -c 0 |
|                                                     {-4} | 0 0  0 0  0 0  e |
|                                                                             |
|                                        1                                    |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o9 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|0  0 0 |, {-4} | d -c -b a 0  0  0  0  0 |) <-- subquotient ({-3} | c b a  0 |
|a  0 0 |  {-4} | e 0  0  0 -c -b a  0  0 |                   {-3} | d 0 0  b |
|0  a 0 |  {-4} | 0 e  0  0 -d 0  0  -b a |                   {-3} | 0 d 0  -c|
|0  0 a |  {-4} | 0 0  e  0 0  -d 0  c  0 |                   {-3} | 0 0 -d 0 |
|-d c b |  {-4} | 0 0  0  e 0  0  -d 0  c |                   {-3} | e 0 0  0 |
|                                                             {-3} | 0 e 0  0 |
|                                                             {-3} | 0 0 -e 0 |
|                                                             {-3} | 0 0 0  e |
|                                                             {-3} | 0 0 0  0 |
|                                                                             |
|                                                2                            |
|-----------------------------------------------------------------------------|
|0  0  0 |, {-3} | -b a  0  0  0  0 |) <-- subquotient ({-2} | ac |, {-2} | ac|
|0  a  0 |  {-3} | 0  0  -b a  0  0 |                   {-2} | bc |  {-2} | bc|
|0  0  0 |  {-3} | -d 0  c  0  0  0 |                   {-2} | ad |  {-2} | ad|
|0  c  0 |  {-3} | 0  -d 0  c  0  0 |                   {-2} | bd |  {-2} | bd|
|b  0  a |  {-3} | 0  0  0  0  -b a |                   {-2} | ae |  {-2} | ae|
|-c 0  0 |  {-3} | -e 0  0  0  c  0 |                   {-2} | be |  {-2} | be|
|0  0  c |  {-3} | 0  -e 0  0  0  c |                                         |
|-d 0  0 |  {-3} | 0  0  -e 0  d  0 |      3                                  |
|0  -e d |  {-3} | 0  0  0  -e 0  d |                                         |
|-----------------------------------------------------------------------------|
||) <-- image 0                                                               |
||                                                                            |
||      4                                                                     |
||                                                                            |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i10 : prune H                                                                |
|                                                                             |
|o10 = cokernel {-5} | e d c b a | <-- cokernel {-3} | e d c | <-- cokernel   |
|                                                                             |
|      0                               1                           2          |
|                                                                             |
|o10 : Complex                                                                |
|-----------------------------------------------------------------------------|
|{-2} | b a |                                                                 |
+-----------------------------------------------------------------------------+
|i11 : dd^H == 0                                                              |
|                                                                             |
|o11 = true                                                                   |
+-----------------------------------------------------------------------------+
|i12 : assert(H == gradedModule H)                                            |
+-----------------------------------------------------------------------------+

See also
========

  * HH Complex -- homology of a complex

Ways to use this method:
========================

  * gradedModule(Complex) -- a new complex in
    which the differential is zero

HH Complex -- homology of a complex
***********************************

Synopsis
========

  * Function: homology (Macaulay2Doc),
  * Usage:
        H = HH C
  * Inputs:
      * C, a complex,
  * Outputs:
      * H, a complex,

Description
===========

The homology complex $H$ is defined by ker dd^C/image dd^C. The differential of
the homology complex is the zero map.

The first example is the complex associated to a triangulation of the real
projective plane, having 6 vertices, 15 edges, and 10 triangles.

+-----------------------------------------------------------------------------+
|i1 : d1 = matrix {                                                           |
|         {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},                      |
|         {-1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},                     |
|         {0, -1, 0, 0, 0, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0},                    |
|         {0, 0, -1, 0, 0, 0, -1, 0, 0, -1, 0, 0, 1, 1, 0},                   |
|         {0, 0, 0, -1, 0, 0, 0, -1, 0, 0, -1, 0, -1, 0, 1},                  |
|         {0, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, -1, 0, -1, -1}}                 |
|                                                                             |
|o1 = | 1  1  1  1  1  0  0  0  0  0  0  0  0  0  0  |                        |
|     | -1 0  0  0  0  1  1  1  1  0  0  0  0  0  0  |                        |
|     | 0  -1 0  0  0  -1 0  0  0  1  1  1  0  0  0  |                        |
|     | 0  0  -1 0  0  0  -1 0  0  -1 0  0  1  1  0  |                        |
|     | 0  0  0  -1 0  0  0  -1 0  0  -1 0  -1 0  1  |                        |
|     | 0  0  0  0  -1 0  0  0  -1 0  0  -1 0  -1 -1 |                        |
|                                                                             |
|              6        15                                                    |
|o1 : Matrix ZZ  <--- ZZ                                                      |
+-----------------------------------------------------------------------------+
|i2 : d2 = matrix {                                                           |
|         {-1, -1, 0, 0, 0, 0, 0, 0, 0, 0},                                   |
|         {0, 0, -1, -1, 0, 0, 0, 0, 0, 0},                                   |
|         {1, 0, 1, 0, 0, 0, 0, 0, 0, 0},                                     |
|         {0, 1, 0, 0, -1, 0, 0, 0, 0, 0},                                    |
|         {0, 0, 0, 1, 1, 0, 0, 0, 0, 0},                                     |
|         {0, 0, 0, 0, 0, -1, -1, 0, 0, 0},                                   |
|         {-1, 0, 0, 0, 0, 0, 0, -1, 0, 0},                                   |
|         {0, -1, 0, 0, 0, 1, 0, 0, 0, 0},                                    |
|         {0, 0, 0, 0, 0, 0, 1, 1, 0, 0},                                     |
|         {0, 0, -1, 0, 0, 0, 0, 0, -1, 0},                                   |
|         {0, 0, 0, 0, 0, -1, 0, 0, 1, 0},                                    |
|         {0, 0, 0, -1, 0, 0, -1, 0, 0, 0},                                   |
|         {0, 0, 0, 0, 0, 0, 0, 0, -1, -1},                                   |
|         {0, 0, 0, 0, 0, 0, 0, -1, 0, 1},                                    |
|         {0, 0, 0, 0, -1, 0, 0, 0, 0, -1}}                                   |
|                                                                             |
|o2 = | -1 -1 0  0  0  0  0  0  0  0  |                                       |
|     | 0  0  -1 -1 0  0  0  0  0  0  |                                       |
|     | 1  0  1  0  0  0  0  0  0  0  |                                       |
|     | 0  1  0  0  -1 0  0  0  0  0  |                                       |
|     | 0  0  0  1  1  0  0  0  0  0  |                                       |
|     | 0  0  0  0  0  -1 -1 0  0  0  |                                       |
|     | -1 0  0  0  0  0  0  -1 0  0  |                                       |
|     | 0  -1 0  0  0  1  0  0  0  0  |                                       |
|     | 0  0  0  0  0  0  1  1  0  0  |                                       |
|     | 0  0  -1 0  0  0  0  0  -1 0  |                                       |
|     | 0  0  0  0  0  -1 0  0  1  0  |                                       |
|     | 0  0  0  -1 0  0  -1 0  0  0  |                                       |
|     | 0  0  0  0  0  0  0  0  -1 -1 |                                       |
|     | 0  0  0  0  0  0  0  -1 0  1  |                                       |
|     | 0  0  0  0  -1 0  0  0  0  -1 |                                       |
|                                                                             |
|              15        10                                                   |
|o2 : Matrix ZZ   <--- ZZ                                                     |
+-----------------------------------------------------------------------------+
|i3 : C = complex {d1,d2}                                                     |
|                                                                             |
|       6       15       10                                                   |
|o3 = ZZ  <-- ZZ   <-- ZZ                                                     |
|                                                                             |
|     0       1        2                                                      |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : dd^C                                                                    |
|                                                                             |
|           6                                                         15      |
|o4 = 0 : ZZ  <---------------------------------------------------- ZZ   : 1  |
|                | 1  1  1  1  1  0  0  0  0  0  0  0  0  0  0  |             |
|                | -1 0  0  0  0  1  1  1  1  0  0  0  0  0  0  |             |
|                | 0  -1 0  0  0  -1 0  0  0  1  1  1  0  0  0  |             |
|                | 0  0  -1 0  0  0  -1 0  0  -1 0  0  1  1  0  |             |
|                | 0  0  0  -1 0  0  0  -1 0  0  -1 0  -1 0  1  |             |
|                | 0  0  0  0  -1 0  0  0  -1 0  0  -1 0  -1 -1 |             |
|                                                                             |
|           15                                          10                    |
|     1 : ZZ   <------------------------------------- ZZ   : 2                |
|                 | -1 -1 0  0  0  0  0  0  0  0  |                           |
|                 | 0  0  -1 -1 0  0  0  0  0  0  |                           |
|                 | 1  0  1  0  0  0  0  0  0  0  |                           |
|                 | 0  1  0  0  -1 0  0  0  0  0  |                           |
|                 | 0  0  0  1  1  0  0  0  0  0  |                           |
|                 | 0  0  0  0  0  -1 -1 0  0  0  |                           |
|                 | -1 0  0  0  0  0  0  -1 0  0  |                           |
|                 | 0  -1 0  0  0  1  0  0  0  0  |                           |
|                 | 0  0  0  0  0  0  1  1  0  0  |                           |
|                 | 0  0  -1 0  0  0  0  0  -1 0  |                           |
|                 | 0  0  0  0  0  -1 0  0  1  0  |                           |
|                 | 0  0  0  -1 0  0  -1 0  0  0  |                           |
|                 | 0  0  0  0  0  0  0  0  -1 -1 |                           |
|                 | 0  0  0  0  0  0  0  -1 0  1  |                           |
|                 | 0  0  0  0  -1 0  0  0  0  -1 |                           |
|                                                                             |
|o4 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i5 : H = HH C                                                                |
|                                                                             |
|o5 = cokernel | 1  1  1  1  1  0  0  0  0  0  0  0  0  0  0  | <--           |
|              | -1 0  0  0  0  1  1  1  1  0  0  0  0  0  0  |               |
|              | 0  -1 0  0  0  -1 0  0  0  1  1  1  0  0  0  |               |
|              | 0  0  -1 0  0  0  -1 0  0  -1 0  0  1  1  0  |               |
|              | 0  0  0  -1 0  0  0  -1 0  0  -1 0  -1 0  1  |               |
|              | 0  0  0  0  -1 0  0  0  -1 0  0  -1 0  -1 -1 |               |
|                                                                             |
|     0                                                                       |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o5 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|subquotient (| 0  1  0  0  0  0  0  0  0  0  |, | -1 -1 0  0  0  0  0  0  0  |
|             | 1  0  0  0  0  0  0  0  0  0  |  | 0  0  -1 -1 0  0  0  0  0  |
|             | 0  -1 1  0  -1 0  1  0  1  0  |  | 1  0  1  0  0  0  0  0  0  |
|             | 0  0  0  0  0  1  0  0  0  0  |  | 0  1  0  0  -1 0  0  0  0  |
|             | -1 0  -1 0  1  -1 -1 0  -1 0  |  | 0  0  0  1  1  0  0  0  0  |
|             | 0  0  0  0  1  0  0  0  0  0  |  | 0  0  0  0  0  -1 -1 0  0  |
|             | 0  0  0  1  0  0  0  0  1  1  |  | -1 0  0  0  0  0  0  -1 0  |
|             | 0  1  -1 0  0  0  0  0  -1 0  |  | 0  -1 0  0  0  1  0  0  0  |
|             | 0  0  1  -1 -1 0  0  0  0  -1 |  | 0  0  0  0  0  0  1  1  0  |
|             | 0  0  0  0  0  0  0  1  0  0  |  | 0  0  -1 0  0  0  0  0  -1 |
|             | 0  0  0  0  0  0  0  0  0  1  |  | 0  0  0  0  0  -1 0  0  1  |
|             | 1  0  0  0  1  0  0  -1 0  -1 |  | 0  0  0  -1 0  0  -1 0  0  |
|             | 0  -1 1  0  -1 0  1  1  2  1  |  | 0  0  0  0  0  0  0  0  -1 |
|             | 0  0  0  1  0  0  0  0  0  0  |  | 0  0  0  0  0  0  0  -1 0  |
|             | 0  0  0  0  -1 1  1  1  1  2  |  | 0  0  0  0  -1 0  0  0  0  |
|                                                                             |
|1                                                                            |
|-----------------------------------------------------------------------------|
|0  |) <-- image 0                                                            |
|0  |                                                                         |
|0  |      2                                                                  |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|-1 |                                                                         |
|1  |                                                                         |
|-1 |                                                                         |
+-----------------------------------------------------------------------------+
|i6 : dd^H == 0                                                               |
|                                                                             |
|o6 = true                                                                    |
+-----------------------------------------------------------------------------+

To see that the first homology group has torsion, we compute a minimal
presentation of the homology.

+---------------------------+
|i7 : Hpruned = prune HH C  |
|                           |
|       1                   |
|o7 = ZZ  <-- cokernel | 2 ||
|                           |
|     0       1             |
|                           |
|o7 : Complex               |
+---------------------------+
|i8 : dd^Hpruned == 0       |
|                           |
|o8 = true                  |
+---------------------------+

By dualizing the minimal free resolution of a monomial ideal, we get a free
complex with non-trivial homology.  This particular complex is related to the
local cohomology supported at the monomial ideal.

+-----------------------------------------------------------------------------+
|i9 : S = ZZ/101[a..d, DegreeRank=>4];                                        |
+-----------------------------------------------------------------------------+
|i10 : I = intersect(ideal(a,b),ideal(c,d))                                   |
|                                                                             |
|o10 = ideal (b*d, a*d, b*c, a*c)                                             |
|                                                                             |
|o10 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i11 : C = freeResolution (S^1/I)                                             |
|                                                                             |
|       1      4      4      1                                                |
|o11 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o11 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i12 : prune HH C                                                             |
|                                                                             |
|o12 = cokernel | bd ad bc ac |                                               |
|                                                                             |
|      0                                                                      |
|                                                                             |
|o12 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i13 : Cdual = dual C                                                         |
|                                                                             |
|       1      4      4      1                                                |
|o13 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      -3     -2     -1     0                                                 |
|                                                                             |
|o13 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i14 : prune HH Cdual                                                         |
|                                                                             |
|o14 = cokernel {-1, -1, -1, -1} | d c b a | <-- cokernel {-1, -1, 0, 0} | b a|
|                                                         {0, 0, -1, -1} | 0 0|
|      -3                                                                     |
|                                                -2                           |
|                                                                             |
|o14 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0 0 |                                                                        |
|d c |                                                                        |
+-----------------------------------------------------------------------------+
|i15 : prune HH_(-2) Cdual                                                    |
|                                                                             |
|o15 = cokernel {-1, -1, 0, 0} | b a 0 0 |                                    |
|               {0, 0, -1, -1} | 0 0 d c |                                    |
|                                                                             |
|                             2                                               |
|o15 : S-module, quotient of S                                                |
+-----------------------------------------------------------------------------+

See also
========

  * dual(Complex) -- make the dual of a complex
  * prune(Complex) -- minimal
    presentation of all terms in a complex

Ways to use this method:
========================

  * HH Complex -- homology of a complex

HH ComplexMap -- induced map on homology or cohomology
******************************************************

Synopsis
========

  * Function: homology (Macaulay2Doc),
  * Usage:
        h = HH f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * h, a map of complexes,

Description
===========

Homology defines a functor from the category of chain complexes to itself.
Given a map of chain complexes $f : C \to D$, this method returns the induced
map $HH f : HH C \to HH D$.

To directly obtain the $n$-th map in $h$, use HH_n f or HH^n f.  By definition
HH^n f === HH_(-n) f. This can be more efficient, as it will compute only the
desired induced map.

If $f$ commutes with the differentials, then these induced maps are well
defined.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..d]                                                        |
|                                                                             |
|o1 = S                                                                       |
|                                                                             |
|o1 : PolynomialRing                                                          |
+-----------------------------------------------------------------------------+
|i2 : I = ideal(a*b, a*d, c*b, c*d)                                           |
|                                                                             |
|o2 = ideal (a*b, a*d, b*c, c*d)                                              |
|                                                                             |
|o2 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i3 : C = (dual freeResolution I)[1]                                          |
|                                                                             |
|      1      4      4      1                                                 |
|o3 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     -4     -3     -2     -1                                                 |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : D = dual complex for i from 0 to 4 list koszul(i,gens I)                |
|                                                                             |
|      1      4      6      4      1                                          |
|o4 = S  <-- S  <-- S  <-- S  <-- S  <-- 0                                    |
|                                                                             |
|     -5     -4     -3     -2     -1     0                                    |
|                                                                             |
|o4 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i5 : assert isWellDefined D                                                  |
+-----------------------------------------------------------------------------+
|i6 : f = randomComplexMap(D, C, Cycle => true)                               |
|                                                                             |
|           4                                1                                |
|o6 = -4 : S  <---------------------------- S  : -4                           |
|                {-6} | -30ab+24bc-36ad |                                     |
|                {-6} | -29ab-10ad+24cd |                                     |
|                {-6} | 19ab+19bc+36cd  |                                     |
|                {-6} | 29bc+19ad-cd    |                                     |
|                                                                             |
|           6                                                    4            |
|     -3 : S  <------------------------------------------------ S  : -3       |
|                {-4} | -24d     -29a+24c 24b      -24a     |                 |
|                {-4} | -29b-36d 36c      36b      -36a     |                 |
|                {-4} | d        -c       -30b     30a      |                 |
|                {-4} | -10d     -19c     -19b     -10a     |                 |
|                {-4} | 29d      -29c     -29b-29d 29a      |                 |
|                {-4} | -19d     19c      19b      -19a-29c |                 |
|                                                                             |
|           4                            4                                    |
|     -2 : S  <------------------------ S  : -2                               |
|                {-2} | 29 0  0  0  |                                         |
|                {-2} | 0  0  29 0  |                                         |
|                {-2} | 0  29 0  0  |                                         |
|                {-2} | 0  0  0  29 |                                         |
|                                                                             |
|           1               1                                                 |
|     -1 : S  <----------- S  : -1                                            |
|                | -29 |                                                      |
|                                                                             |
|o6 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i7 : assert isCommutative f                                                  |
+-----------------------------------------------------------------------------+
|i8 : h = HH f                                                                |
|                                                                             |
|o8 = -4 : subquotient ({-6} | b a  0 0  |, {-6} | bc -ad ab 0   0   0  |)    |
|                       {-6} | d 0  0 a  |  {-6} | cd 0   0  -ad ab  0  |     |
|                       {-6} | 0 -c b 0  |  {-6} | 0  cd  0  -bc 0   ab |     |
|                       {-6} | 0 0  d -c |  {-6} | 0  0   cd 0   -bc ad |     |
|                                                                             |
|                                                                             |
|     -3 : subquotient ({-4} | ad 0  ab  0   a2  0  |, {-4} | -ad ab  0       |
|                       {-4} | bc b2 0   ab  0   0  |  {-4} | -bc 0   ab      |
|                       {-4} | 0  bd -bc ad  -ac 0  |  {-4} | 0   -bc ad      |
|                       {-4} | cd bd 0   0   ac  ab |  {-4} | -cd 0   0       |
|                       {-4} | 0  d2 -cd 0   0   ad |  {-4} | 0   -cd 0       |
|                       {-4} | 0  0  0   -cd c2  bc |  {-4} | 0   0   -cd     |
|                                                                             |
|                                                                             |
|     -2 : subquotient ({-2} | ab |, {-2} | ab |) <----- subquotient ({-2}    |
|                       {-2} | ad |  {-2} | ad |     0                {-2}    |
|                       {-2} | bc |  {-2} | bc |                      {-2}    |
|                       {-2} | cd |  {-2} | cd |                      {-2}    |
|                                                                             |
|     -1 : image 0 <----- image 0 : -1                                        |
|                     0                                                       |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
| <----------------- cokernel {-4} | -d c b -a | : -4                         |
|    {-5} | 0    |                                                            |
|    {-5} | 0    |                                                            |
|    {-5} | 0    |                                                            |
|    {-5} | -29d |                                                            |
|                                                                             |
|0  |) <---------------------------- subquotient ({-3} | c b 0  a  0 0 |, {-3}|
|0  |     {-2} | 0 0   0 0 0   0 |                {-3} | d 0 b  0  a 0 |  {-3}|
|0  |     {-2} | 0 -29 0 0 0   0 |                {-3} | 0 d -c 0  0 a |  {-3}|
|ab |     {-2} | 0 0   0 0 0   0 |                {-3} | 0 0 0  -d c b |  {-3}|
|ad |     {-2} | 0 0   0 0 0   0 |                                            |
|bc |     {-2} | 0 0   0 0 -29 0 |                                            |
|         {-2} | 0 0   0 0 0   0 |                                            |
|                                                                             |
| | ab |, {-2} | -ab |) : -2                                                  |
| | bc |  {-2} | -bc |                                                        |
| | ad |  {-2} | -ad |                                                        |
| | cd |  {-2} | -cd |                                                        |
|-----------------------------------------------------------------------------|
|| c -a 0  0  |) : -3                                                         |
|| d 0  -b 0  |                                                               |
|| 0 0  c  -a |                                                               |
|| 0 d  0  -b |                                                               |
+-----------------------------------------------------------------------------+
|i9 : assert isWellDefined h                                                  |
+-----------------------------------------------------------------------------+
|i10 : prune h                                                                |
|                                                                             |
|o10 = -4 : cokernel {-5} | c 0 0 a  0  0 0 | <----------------- cokernel     |
|                    {-5} | 0 d 0 0  b  0 0 |    {-5} | 0    |                |
|                    {-5} | 0 0 a 0  0  c 0 |    {-5} | 0    |                |
|                    {-5} | 0 0 0 -d -d d b |    {-5} | 0    |                |
|                                                {-5} | -29d |                |
|                                                                             |
|      -3 : cokernel {-2} | c a 0 0 | <-------------------- cokernel {-2}     |
|                    {-2} | 0 0 d b |    {-2} | -29 0   |            {-2}     |
|                                        {-2} | 0   -29 |                     |
|                                                                             |
|o10 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|{-4} | d c b a | : -4                                                        |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|| c a 0 0 | : -3                                                             |
|| 0 0 d b |                                                                  |
+-----------------------------------------------------------------------------+
|i11 : assert(source h == HH C)                                               |
+-----------------------------------------------------------------------------+
|i12 : assert(target h == HH D)                                               |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i13 : f2 = randomComplexMap(D, C, Cycle => true, Degree => -1)               |
|                                                                             |
|            1                                                                |
|o13 = -5 : S  <--------------------------------------------------------------|
|                 {-8} | 19a3b-47a2b2-13ab3-42a2bc-21ab2c-23b3c+26abc2-7b2c2+2|
|                                                                             |
|            4                                                                |
|      -4 : S  <--------------------------------------------------------------|
|                 {-6} | 48a2b-26ab2-5b3+13abc-8b2c-2bc2-22a2d+33abd+38b2d+40a|
|                 {-6} | -26a2b+22ab2-49abc+20a2d-22abd-28b2d-26acd-15bcd+27c2|
|                 {-6} | -17a2b-12ab2+14b3-abc-7b2c-39bc2+29a2d-25abd+42acd-13|
|                 {-6} | 26abc-22b2c+49bc2+2a2d+42abd+b2d-15acd-32bcd+26c2d+50|
|                                                                             |
|            6                                                                |
|      -3 : S  <--------------------------------------------------------------|
|                 {-4} | 4a2+12ab+5b2+2ac+8bc+2c2-8ad+40bd+48cd+22d2        -4|
|                 {-4} | -37a2+31ab+29b2-30ac-28bc-12c2+30ad-39bd+14cd+32d2 6a|
|                 {-4} | 49ac+14bc-15c2+44ad+47bd+35cd+23d2                 48|
|                 {-4} | -9a2+46ab+14b2+7ac-7bc-39c2+24ad+5bd-37cd+33d2     16|
|                 {-4} | 26ac-22bc+49c2-23ad+44bd-28cd+20d2                 -2|
|                 {-4} | 8ac-43bc+8c2-16ad+28bd-30cd-35d2                   -1|
|                                                                             |
|            4                                                                |
|      -2 : S  <--------------------------------------------------------------|
|                 {-2} | 27a2+4ab-20b2+4ac-20bc-37c2-16ad+9bd+36cd-14d2    |  |
|                 {-2} | 4a2+12ab+5b2-47ac-25bc-17c2-9ad-bd+36cd+13d2      |  |
|                 {-2} | -37a2+31ab+29b2+3ac+26bc-33c2+23ad+32bd-43cd+49d2 |  |
|                 {-2} | -9a2+46ab+14b2+23ac+39bc+50c2-25ad-5bd-46cd+28d2  |  |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|9bc3-29a3d-26a2bd-39ab2d-20a2cd+32abcd+47b2cd-40ac2d+20bc2d-47c3d-29a2d2+22ab|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|cd+16bcd+47c2d+36ad2-15bd2-47cd2-19d3 -37a3-13a2b-18ab2-8a2c+13abc+23b2c+49ac|
|d-26ad2-16bd2+36cd2-48d3              -9a3-32a2b-30ab2-17a2c+31abc+23b2c-15ac|
|bcd+29ad2+3bd2+44cd2-34d3             16a2b-28ab2+8a2c+48abc-24b2c-12ac2+4bc2|
|ad2-39bd2-23cd2+25d3                  -10a2c-22abc+43b2c-42ac2-10bc2-11c3+16a|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|9a2-33ab-19ac+26ad+35bd-6cd-40d2                 -27a2-5ab-21b2-7ac+22bc+12c2|
|2+50ab+20b2-25ac+20bc+37c2+42ad+44bd+36cd-34d2   -7ab-30b2-41ac+39bc-13c2+17b|
|a2-26ab-5b2-39ac+25bc+17c2-25ad+19bd+19cd-14d2   -37a2-13ab-18b2-27ac+44bc+41|
|a2+46ab-12ac-12ad+37bd-47cd+49d2                 -49ab-10b2-13ac-24bc-41c2-5b|
|6a2+22ab-49ac-11ad+40bd-22cd+10d2                -9a2-32ab-30b2-20ac-48bc+39c|
|7a2-12ab+14b2+15ac+39bc+50c2-33ad-24bd+11cd-13d2 16ab-28b2-37ac+29bc+31c2+35b|
|                                                                             |
|  1                                                                          |
| S  : -1                                                                     |
|-----------------------------------------------------------------------------|
|                                         1                                   |
|--------------------------------------- S  : -4                              |
|d2+21acd2-33bcd2+47c2d2+34ad3+19cd3 |                                        |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|2+37bc2-47c3+30a2d+39abd-22acd-7bcd+47c2d+32ad2+19cd2 46a2b-26ab2+44b3+15abc+|
|2+7bc2-29c3+24a2d-15abd-3acd-24bcd+17c2d+33ad2+26cd2  3a2b-22ab2+23b3+47abc+7|
|+12c3+35abd+42acd-32bcd+43c2d+2cd2                    45a2b-30ab2-34b3+45abc-|
|2d-28abd+37acd+12bcd-12c2d+35ad2-48cd2                -19a2b+47ab2+13b3+39abc|
|                                                                             |
|                                                                             |
|--------------------------------------------------------------------------- S|
|+16ad-18bd-34cd+14d2  3a2-40ab-35b2+25ac+6bc-2ad+40bd                   |    |
|d+4cd                 41a2-21ab+48b2+13ac+29bc-4ad+48bd                 |    |
|c2+23ad+9bd-3cd+49d2  30a2-19ab-18b2+27ac+46bc-40ad+bd                  |    |
|d+8cd                 -14a2+23ab-17b2+37ac-34bc+37c2+8ad+43bd-36cd+14d2 |    |
|2-25ad-25bd-27cd+28d2 39a2+13ab-45b2-43ac+47bc+17c2-10ad-9bd-36cd-13d2  |    |
|d+39cd                -27a2-22ab-10b2-34ac+18bc+33c2+39ad+9bd+43cd-49d2 |    |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|15b2c+42bc2-41a2d+4abd+11b2d-13acd-20bcd+4ad2+5bd2                  -16a3+7a2|
|b2c-29bc2+14a2d+5abd-3b2d-34acd-5bcd-12c2d-8ad2+44bd2+34cd2-14d3    36a3+35a2|
|20b2c-29bc2+10abd-7b2d+41acd+12bcd+13c2d-15bd2-4cd2                 29a3+8a2b|
|+43b2c+28bc2-27a2d-4abd+5b2d-4acd+18bcd-41c2d+39ad2-29bd2+3cd2-49d3 19a3-47a2|
|                                                                             |
|4                                                                            |
|  : -2                                                                       |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|b+39ab2+15a2c-9abc-35b2c-17ac2+6bc2-23a2d+43abd-11acd+40bcd+48ad2            |
|b+33ab2+11a2c+40abc+46ac2-38a2d+11abd-37acd-35bcd+6c2d+ad2+40cd2             |
|+24ab2+36a2c+15abc+17b2c+25ac2+34bc2-37c3+29a2d+16abd+2acd+5bcd-36c2d-34ad2+3|
|b-13ab2+23a2c+45abc+45b2c+15ac2-47bc2-17c3-18a2d-15abd-9acd-9bcd-19c2d+38ad2+|
|-----------------------------------------------------------------------------|
|           4                                                                 |
|--------- S  : -3                                                            |
|      |                                                                      |
|      |                                                                      |
|4cd2  |                                                                      |
|14cd2 |                                                                      |
+-----------------------------------------------------------------------------+
|i14 : h2 = HH f2                                                             |
|                                                                             |
|o14 = -5 : cokernel {-8} | -cd                                               |
|                                                                             |
|                                                                             |
|      -4 : subquotient ({-6} |                                               |
|                        {-6} |                                               |
|                        {-6} |                                               |
|                        {-6} |                                               |
|                                                                             |
|                                                                             |
|      -3 : subquotient ({-4} |                                               |
|                        {-4} |                                               |
|                        {-4} |                                               |
|                        {-4} |                                               |
|                        {-4} |                                               |
|                        {-4} |                                               |
|                                                                             |
|      -2 : subquotient ({-2} |                                               |
|                        {-2} |                                               |
|                        {-2} |                                               |
|                        {-2} |                                               |
|                                                                             |
|o14 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|bc -ad ab | <----- cokernel {-4} | -d c b -                                  |
|               0                                                             |
|                                                                             |
|b a  0 0  |, {-6} | bc -ad ab 0   0   0  |)                                  |
|d 0  0 a  |  {-6} | cd 0   0  -ad ab  0  |                                   |
|0 -c b 0  |  {-6} | 0  cd  0  -bc 0   ab |                                   |
|0 0  d -c |  {-6} | 0  0   cd 0   -bc ad |                                   |
|                                                                             |
|                                                                             |
|ad 0  ab  0   a2  0  |, {-4} | -ad ab  0                                     |
|bc b2 0   ab  0   0  |  {-4} | -bc 0   ab                                    |
|0  bd -bc ad  -ac 0  |  {-4} | 0   -bc ad                                    |
|cd bd 0   0   ac  ab |  {-4} | -cd 0   0                                     |
|0  d2 -cd 0   0   ad |  {-4} | 0   -cd 0                                     |
|0  0  0   -cd c2  bc |  {-4} | 0   0   -cd                                   |
|                                                                             |
|ab |, {-2} | ab |) <----- image 0 : -1                                       |
|ad |  {-2} | ad |     0                                                      |
|bc |  {-2} | bc |                                                            |
|cd |  {-2} | cd |                                                            |
|-----------------------------------------------------------------------------|
|a | : -4                                                                     |
|                                                                             |
|                                                                             |
| <----------------------------------------------------------------           |
|    {-5} | 0 -5b3-19b2d-4bd2-14d3 0 0 0                      0 |             |
|    {-5} | 0 0                    0 0 -37a3-24a2c-37ac2+37c3 0 |             |
|    {-5} | 0 14b3-34b2d-4bd2-49d3 0 0 0                      0 |             |
|    {-5} | 0 0                    0 0 -9a3+19a2c-4ac2+17c3   0 |             |
|                                                                             |
|0  |) <----- subquotient ({-2} | ab |, {-2} | -ab |) : -2                    |
|0  |     0                {-2} | bc |  {-2} | -bc |                          |
|0  |                      {-2} | ad |  {-2} | -ad |                          |
|ab |                      {-2} | cd |  {-2} | -cd |                          |
|ad |                                                                         |
|bc |                                                                         |
|-----------------------------------------------------------------------------|
|subquotient ({-3} | c b 0  a  0 0 |, {-3} | c -a 0  0  |) : -3               |
|             {-3} | d 0 b  0  a 0 |  {-3} | d 0  -b 0  |                     |
|             {-3} | 0 d -c 0  0 a |  {-3} | 0 0  c  -a |                     |
|             {-3} | 0 0 0  -d c b |  {-3} | 0 d  0  -b |                     |
+-----------------------------------------------------------------------------+
|i15 : assert isWellDefined h2                                                |
+-----------------------------------------------------------------------------+
|i16 : prune h2                                                               |
|                                                                             |
|o16 = -4 : cokernel {-5} | c 0 0 a  0  0 0 |                                 |
|                    {-5} | 0 d 0 0  b  0 0 |                                 |
|                    {-5} | 0 0 a 0  0  c 0 |                                 |
|                    {-5} | 0 0 0 -d -d d b |                                 |
|                                                                             |
|                                                                             |
|o16 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|<-------------------------------------------------------- cokernel {-2} | c a|
|   {-5} | -5b3-19b2d-4bd2-14d3 0                      |            {-2} | 0 0|
|   {-5} | 0                    -37a3-24a2c-37ac2+37c3 |                      |
|   {-5} | 14b3-34b2d-4bd2-49d3 0                      |                      |
|   {-5} | 0                    -9a3+19a2c-4ac2+17c3   |                      |
|-----------------------------------------------------------------------------|
|0 0 | : -3                                                                   |
|d b |                                                                        |
+-----------------------------------------------------------------------------+

A boundary will always induce the zero map.

+-----------------------------------------------------------------------------+
|i17 : f3 = randomComplexMap(D, C, Boundary => true)                          |
|                                                                             |
|            4                                1                               |
|o17 = -4 : S  <---------------------------- S  : -4                          |
|                 {-6} | -47ab+19bc      |                                    |
|                 {-6} | 47ab+28ad+19cd  |                                    |
|                 {-6} | -28ab+28bc      |                                    |
|                 {-6} | -47bc-28ad-47cd |                                    |
|                                                                             |
|            6                                    4                           |
|      -3 : S  <-------------------------------- S  : -3                      |
|                 {-4} | -19d 19c  19b  -19a |                                |
|                 {-4} | 0    0    0    0    |                                |
|                 {-4} | 47d  -47c -47b 47a  |                                |
|                 {-4} | 28d  -28c -28b 28a  |                                |
|                 {-4} | -47d 47c  47b  -47a |                                |
|                 {-4} | 28d  -28c -28b 28a  |                                |
|                                                                             |
|            4         4                                                      |
|      -2 : S  <----- S  : -2                                                 |
|                 0                                                           |
|                                                                             |
|            1         1                                                      |
|      -1 : S  <----- S  : -1                                                 |
|                 0                                                           |
|                                                                             |
|o17 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i18 : h3 = HH f3                                                             |
|                                                                             |
|o18 = -4 : subquotient ({-6} | b a  0 0  |, {-6} | bc -ad ab 0   0   0  |)   |
|                        {-6} | d 0  0 a  |  {-6} | cd 0   0  -ad ab  0  |    |
|                        {-6} | 0 -c b 0  |  {-6} | 0  cd  0  -bc 0   ab |    |
|                        {-6} | 0 0  d -c |  {-6} | 0  0   cd 0   -bc ad |    |
|                                                                             |
|      -3 : subquotient ({-4} | ad 0  ab  0   a2  0  |, {-4} | -ad ab  0      |
|                        {-4} | bc b2 0   ab  0   0  |  {-4} | -bc 0   ab     |
|                        {-4} | 0  bd -bc ad  -ac 0  |  {-4} | 0   -bc ad     |
|                        {-4} | cd bd 0   0   ac  ab |  {-4} | -cd 0   0      |
|                        {-4} | 0  d2 -cd 0   0   ad |  {-4} | 0   -cd 0      |
|                        {-4} | 0  0  0   -cd c2  bc |  {-4} | 0   0   -cd    |
|                                                                             |
|      -2 : subquotient ({-2} | ab |, {-2} | ab |) <----- subquotient ({-2}   |
|                        {-2} | ad |  {-2} | ad |     0                {-2}   |
|                        {-2} | bc |  {-2} | bc |                      {-2}   |
|                        {-2} | cd |  {-2} | cd |                      {-2}   |
|                                                                             |
|      -1 : image 0 <----- image 0 : -1                                       |
|                      0                                                      |
|                                                                             |
|o18 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
| <----- cokernel {-4} | -d c b -a | : -4                                     |
|    0                                                                        |
|                                                                             |
|                                                                             |
|                                                                             |
|0  |) <----- subquotient ({-3} | c b 0  a  0 0 |, {-3} | c -a 0  0  |) : -3  |
|0  |     0                {-3} | d 0 b  0  a 0 |  {-3} | d 0  -b 0  |        |
|0  |                      {-3} | 0 d -c 0  0 a |  {-3} | 0 0  c  -a |        |
|ab |                      {-3} | 0 0 0  -d c b |  {-3} | 0 d  0  -b |        |
|ad |                                                                         |
|bc |                                                                         |
|                                                                             |
| | ab |, {-2} | -ab |) : -2                                                  |
| | bc |  {-2} | -bc |                                                        |
| | ad |  {-2} | -ad |                                                        |
| | cd |  {-2} | -cd |                                                        |
+-----------------------------------------------------------------------------+
|i19 : assert isWellDefined h3                                                |
+-----------------------------------------------------------------------------+
|i20 : assert(h3 == 0)                                                        |
+-----------------------------------------------------------------------------+

See also
========

  * HH Complex -- homology of a complex
  * HH_ZZ Complex -- homology or cohomology module of a
    complex
  * HH^ZZ Complex -- homology or cohomology module of a
    complex
  * prune(ComplexMap) -- minimal
    presentation of all terms in a complex

Ways to use this method:
========================

  * HH ComplexMap -- induced map on homology or
    cohomology
  * "HH_ZZ ComplexMap"

HH_ZZ Complex -- homology or cohomology module of a complex
***********************************************************

Synopsis
========

  * Function: homology (Macaulay2Doc),
  * Usage:
        HH_i C
        HH^i C
  * Inputs:
      * i, an integer (Macaulay2Doc),
      * C, a complex,
  * Outputs:
      * a module (Macaulay2Doc), the $i$-th homology or
        cohomology of the complex

Description
===========

The $i$-th homology of a complex $C$ is the quotient (ker dd^C_i/image
dd^C_(i+1)).

The first example is the complex associated to a triangulation of the real
projective plane, having 6 vertices, 15 edges, and 10 triangles.

+-----------------------------------------------------------------------------+
|i1 : d1 = matrix {                                                           |
|         {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},                      |
|         {-1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},                     |
|         {0, -1, 0, 0, 0, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0},                    |
|         {0, 0, -1, 0, 0, 0, -1, 0, 0, -1, 0, 0, 1, 1, 0},                   |
|         {0, 0, 0, -1, 0, 0, 0, -1, 0, 0, -1, 0, -1, 0, 1},                  |
|         {0, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, -1, 0, -1, -1}};                |
|                                                                             |
|              6        15                                                    |
|o1 : Matrix ZZ  <--- ZZ                                                      |
+-----------------------------------------------------------------------------+
|i2 : d2 = matrix {                                                           |
|         {-1, -1, 0, 0, 0, 0, 0, 0, 0, 0},                                   |
|         {0, 0, -1, -1, 0, 0, 0, 0, 0, 0},                                   |
|         {1, 0, 1, 0, 0, 0, 0, 0, 0, 0},                                     |
|         {0, 1, 0, 0, -1, 0, 0, 0, 0, 0},                                    |
|         {0, 0, 0, 1, 1, 0, 0, 0, 0, 0},                                     |
|         {0, 0, 0, 0, 0, -1, -1, 0, 0, 0},                                   |
|         {-1, 0, 0, 0, 0, 0, 0, -1, 0, 0},                                   |
|         {0, -1, 0, 0, 0, 1, 0, 0, 0, 0},                                    |
|         {0, 0, 0, 0, 0, 0, 1, 1, 0, 0},                                     |
|         {0, 0, -1, 0, 0, 0, 0, 0, -1, 0},                                   |
|         {0, 0, 0, 0, 0, -1, 0, 0, 1, 0},                                    |
|         {0, 0, 0, -1, 0, 0, -1, 0, 0, 0},                                   |
|         {0, 0, 0, 0, 0, 0, 0, 0, -1, -1},                                   |
|         {0, 0, 0, 0, 0, 0, 0, -1, 0, 1},                                    |
|         {0, 0, 0, 0, -1, 0, 0, 0, 0, -1}};                                  |
|                                                                             |
|              15        10                                                   |
|o2 : Matrix ZZ   <--- ZZ                                                     |
+-----------------------------------------------------------------------------+
|i3 : C = complex {d1,d2}                                                     |
|                                                                             |
|       6       15       10                                                   |
|o3 = ZZ  <-- ZZ   <-- ZZ                                                     |
|                                                                             |
|     0       1        2                                                      |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : dd^C                                                                    |
|                                                                             |
|           6                                                         15      |
|o4 = 0 : ZZ  <---------------------------------------------------- ZZ   : 1  |
|                | 1  1  1  1  1  0  0  0  0  0  0  0  0  0  0  |             |
|                | -1 0  0  0  0  1  1  1  1  0  0  0  0  0  0  |             |
|                | 0  -1 0  0  0  -1 0  0  0  1  1  1  0  0  0  |             |
|                | 0  0  -1 0  0  0  -1 0  0  -1 0  0  1  1  0  |             |
|                | 0  0  0  -1 0  0  0  -1 0  0  -1 0  -1 0  1  |             |
|                | 0  0  0  0  -1 0  0  0  -1 0  0  -1 0  -1 -1 |             |
|                                                                             |
|           15                                          10                    |
|     1 : ZZ   <------------------------------------- ZZ   : 2                |
|                 | -1 -1 0  0  0  0  0  0  0  0  |                           |
|                 | 0  0  -1 -1 0  0  0  0  0  0  |                           |
|                 | 1  0  1  0  0  0  0  0  0  0  |                           |
|                 | 0  1  0  0  -1 0  0  0  0  0  |                           |
|                 | 0  0  0  1  1  0  0  0  0  0  |                           |
|                 | 0  0  0  0  0  -1 -1 0  0  0  |                           |
|                 | -1 0  0  0  0  0  0  -1 0  0  |                           |
|                 | 0  -1 0  0  0  1  0  0  0  0  |                           |
|                 | 0  0  0  0  0  0  1  1  0  0  |                           |
|                 | 0  0  -1 0  0  0  0  0  -1 0  |                           |
|                 | 0  0  0  0  0  -1 0  0  1  0  |                           |
|                 | 0  0  0  -1 0  0  -1 0  0  0  |                           |
|                 | 0  0  0  0  0  0  0  0  -1 -1 |                           |
|                 | 0  0  0  0  0  0  0  -1 0  1  |                           |
|                 | 0  0  0  0  -1 0  0  0  0  -1 |                           |
|                                                                             |
|o4 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i5 : HH C                                                                    |
|                                                                             |
|o5 = cokernel | 1  1  1  1  1  0  0  0  0  0  0  0  0  0  0  | <--           |
|              | -1 0  0  0  0  1  1  1  1  0  0  0  0  0  0  |               |
|              | 0  -1 0  0  0  -1 0  0  0  1  1  1  0  0  0  |               |
|              | 0  0  -1 0  0  0  -1 0  0  -1 0  0  1  1  0  |               |
|              | 0  0  0  -1 0  0  0  -1 0  0  -1 0  -1 0  1  |               |
|              | 0  0  0  0  -1 0  0  0  -1 0  0  -1 0  -1 -1 |               |
|                                                                             |
|     0                                                                       |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o5 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|subquotient (| 0  1  0  0  0  0  0  0  0  0  |, | -1 -1 0  0  0  0  0  0  0  |
|             | 1  0  0  0  0  0  0  0  0  0  |  | 0  0  -1 -1 0  0  0  0  0  |
|             | 0  -1 1  0  -1 0  1  0  1  0  |  | 1  0  1  0  0  0  0  0  0  |
|             | 0  0  0  0  0  1  0  0  0  0  |  | 0  1  0  0  -1 0  0  0  0  |
|             | -1 0  -1 0  1  -1 -1 0  -1 0  |  | 0  0  0  1  1  0  0  0  0  |
|             | 0  0  0  0  1  0  0  0  0  0  |  | 0  0  0  0  0  -1 -1 0  0  |
|             | 0  0  0  1  0  0  0  0  1  1  |  | -1 0  0  0  0  0  0  -1 0  |
|             | 0  1  -1 0  0  0  0  0  -1 0  |  | 0  -1 0  0  0  1  0  0  0  |
|             | 0  0  1  -1 -1 0  0  0  0  -1 |  | 0  0  0  0  0  0  1  1  0  |
|             | 0  0  0  0  0  0  0  1  0  0  |  | 0  0  -1 0  0  0  0  0  -1 |
|             | 0  0  0  0  0  0  0  0  0  1  |  | 0  0  0  0  0  -1 0  0  1  |
|             | 1  0  0  0  1  0  0  -1 0  -1 |  | 0  0  0  -1 0  0  -1 0  0  |
|             | 0  -1 1  0  -1 0  1  1  2  1  |  | 0  0  0  0  0  0  0  0  -1 |
|             | 0  0  0  1  0  0  0  0  0  0  |  | 0  0  0  0  0  0  0  -1 0  |
|             | 0  0  0  0  -1 1  1  1  1  2  |  | 0  0  0  0  -1 0  0  0  0  |
|                                                                             |
|1                                                                            |
|-----------------------------------------------------------------------------|
|0  |) <-- image 0                                                            |
|0  |                                                                         |
|0  |      2                                                                  |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|0  |                                                                         |
|-1 |                                                                         |
|1  |                                                                         |
|-1 |                                                                         |
+-----------------------------------------------------------------------------+
|i6 : prune HH_0 C                                                            |
|                                                                             |
|       1                                                                     |
|o6 = ZZ                                                                      |
|                                                                             |
|o6 : ZZ-module, free                                                         |
+-----------------------------------------------------------------------------+
|i7 : prune HH_1 C                                                            |
|                                                                             |
|o7 = cokernel | 2 |                                                          |
|                                                                             |
|                              1                                              |
|o7 : ZZ-module, quotient of ZZ                                               |
+-----------------------------------------------------------------------------+
|i8 : prune HH_2 C                                                            |
|                                                                             |
|o8 = 0                                                                       |
|                                                                             |
|o8 : ZZ-module                                                               |
+-----------------------------------------------------------------------------+

The $i$-th cohomology of a complex $C$ is the $(-i)$-th homology of $C$.

+-------------------------------------------+
|i9 : S = ZZ/101[a..d, DegreeRank=>4];      |
+-------------------------------------------+
|i10 : I = intersect(ideal(a,b),ideal(c,d)) |
|                                           |
|o10 = ideal (b*d, a*d, b*c, a*c)           |
|                                           |
|o10 : Ideal of S                           |
+-------------------------------------------+
|i11 : C = dual freeResolution (S^1/I)      |
|                                           |
|       1      4      4      1              |
|o11 = S  <-- S  <-- S  <-- S               |
|                                           |
|      -3     -2     -1     0               |
|                                           |
|o11 : Complex                              |
+-------------------------------------------+
|i12 : prune HH^1 C                         |
|                                           |
|o12 = 0                                    |
|                                           |
|o12 : S-module                             |
+-------------------------------------------+
|i13 : prune HH^2 C                         |
|                                           |
|o13 = cokernel {-1, -1, 0, 0} | b a 0 0 |  |
|               {0, 0, -1, -1} | 0 0 d c |  |
|                                           |
|                             2             |
|o13 : S-module, quotient of S              |
+-------------------------------------------+
|i14 : prune HH^3 C                         |
|                                           |
|o14 = cokernel {-1, -1, -1, -1} | d c b a ||
|                                           |
|                             1             |
|o14 : S-module, quotient of S              |
+-------------------------------------------+

See also
========

  * prune (Macaulay2Doc) -- prune, e.g., compute a minimal
    presentation
  * dual(Complex) -- make the dual of a complex

Ways to use this method:
========================

  * HH_ZZ Complex -- homology or cohomology module of a
    complex

Hom(Complex,Complex) -- the complex of homomorphisms between two complexes
**************************************************************************

Synopsis
========

  * Function: Hom (Macaulay2Doc),
  * Usage:
        D = Hom(C1,C2)
  * Inputs:
      * C1, a complex, or a module (Macaulay2Doc),
        or a ring (Macaulay2Doc),
      * C2, a complex, or a module (Macaulay2Doc),
        or a ring (Macaulay2Doc),
  * Outputs:
      * D, a complex, the complex of homomorphisms between C1
        and C2

Description
===========

The complex of homomorphisms is a complex $D$ whose $i$th component is the
direct sum of $Hom(C1_j, C2_{j+i})$ over all $j$. The differential on
$Hom(C1_j, C2_{j+i})$ is the differential $Hom(id_{C1}, dd^{C2}) + (-1)^j
Hom(dd^{C1}, id_{C2})$. $dd^{C1} \otimes id_{C2} + (-1)^j id_{C1} \otimes
dd^{C2}$.

In particular, for this operation to be well-defined, both arguments must have
the same underlying ring.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..c]                                                        |
|                                                                             |
|o1 = S                                                                       |
|                                                                             |
|o1 : PolynomialRing                                                          |
+-----------------------------------------------------------------------------+
|i2 : C = freeResolution coker vars S                                         |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : D = Hom(C,C)                                                            |
|                                                                             |
|      1      6      15      20      15      6      1                         |
|o3 = S  <-- S  <-- S   <-- S   <-- S   <-- S  <-- S                          |
|                                                                             |
|     -3     -2     -1      0       1       2      3                          |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : dd^D                                                                    |
|                                                                             |
|           1                                6                                |
|o4 = -3 : S  <---------------------------- S  : -2                           |
|                {-3} | c -b a -a -b -c |                                     |
|                                                                             |
|           6                                                      15         |
|     -2 : S  <-------------------------------------------------- S   : -1    |
|                {-2} | -b a  0 a b c 0  0  0  0 0 0 0  0  0  |               |
|                {-2} | -c 0  a 0 0 0 a  b  c  0 0 0 0  0  0  |               |
|                {-2} | 0  -c b 0 0 0 0  0  0  a b c 0  0  0  |               |
|                {-2} | 0  0  0 c 0 0 -b 0  0  a 0 0 -b -c 0  |               |
|                {-2} | 0  0  0 0 c 0 0  -b 0  0 a 0 a  0  -c |               |
|                {-2} | 0  0  0 0 0 c 0  0  -b 0 0 a 0  a  b  |               |
|                                                                             |
|           15                                                                |
|     -1 : S   <--------------------------------------------------------------|
|                 {-1} | a -a -b -c 0  0  0  0  0  0  0  0  0  0  0  0  0  0  |
|                 {-1} | b 0  0  0  -a -b -c 0  0  0  0  0  0  0  0  0  0  0  |
|                 {-1} | c 0  0  0  0  0  0  -a -b -c 0  0  0  0  0  0  0  0  |
|                 {-1} | 0 -b 0  0  a  0  0  0  0  0  b  c  0  0  0  0  0  0  |
|                 {-1} | 0 0  -b 0  0  a  0  0  0  0  -a 0  c  0  0  0  0  0  |
|                 {-1} | 0 0  0  -b 0  0  a  0  0  0  0  -a -b 0  0  0  0  0  |
|                 {-1} | 0 -c 0  0  0  0  0  a  0  0  0  0  0  b  c  0  0  0  |
|                 {-1} | 0 0  -c 0  0  0  0  0  a  0  0  0  0  -a 0  c  0  0  |
|                 {-1} | 0 0  0  -c 0  0  0  0  0  a  0  0  0  0  -a -b 0  0  |
|                 {-1} | 0 0  0  0  -c 0  0  b  0  0  0  0  0  0  0  0  b  c  |
|                 {-1} | 0 0  0  0  0  -c 0  0  b  0  0  0  0  0  0  0  -a 0  |
|                 {-1} | 0 0  0  0  0  0  -c 0  0  b  0  0  0  0  0  0  0  -a |
|                 {-1} | 0 0  0  0  0  0  0  0  0  0  c  0  0  -b 0  0  a  0  |
|                 {-1} | 0 0  0  0  0  0  0  0  0  0  0  c  0  0  -b 0  0  a  |
|                 {-1} | 0 0  0  0  0  0  0  0  0  0  0  0  c  0  0  -b 0  0  |
|                                                                             |
|          20                                                     15          |
|     0 : S   <------------------------------------------------- S   : 1      |
|                | a b c 0  0  0  0  0  0  0  0  0  0  0  0  |                |
|                | a 0 0 -b -c 0  0  0  0  0  0  0  0  0  0  |                |
|                | 0 a 0 a  0  -c 0  0  0  0  0  0  0  0  0  |                |
|                | 0 0 a 0  a  b  0  0  0  0  0  0  0  0  0  |                |
|                | b 0 0 0  0  0  -b -c 0  0  0  0  0  0  0  |                |
|                | 0 b 0 0  0  0  a  0  -c 0  0  0  0  0  0  |                |
|                | 0 0 b 0  0  0  0  a  b  0  0  0  0  0  0  |                |
|                | c 0 0 0  0  0  0  0  0  -b -c 0  0  0  0  |                |
|                | 0 c 0 0  0  0  0  0  0  a  0  -c 0  0  0  |                |
|                | 0 0 c 0  0  0  0  0  0  0  a  b  0  0  0  |                |
|                | 0 0 0 -b 0  0  a  0  0  0  0  0  c  0  0  |                |
|                | 0 0 0 0  -b 0  0  a  0  0  0  0  -b 0  0  |                |
|                | 0 0 0 0  0  -b 0  0  a  0  0  0  a  0  0  |                |
|                | 0 0 0 -c 0  0  0  0  0  a  0  0  0  c  0  |                |
|                | 0 0 0 0  -c 0  0  0  0  0  a  0  0  -b 0  |                |
|                | 0 0 0 0  0  -c 0  0  0  0  0  a  0  a  0  |                |
|                | 0 0 0 0  0  0  -c 0  0  b  0  0  0  0  c  |                |
|                | 0 0 0 0  0  0  0  -c 0  0  b  0  0  0  -b |                |
|                | 0 0 0 0  0  0  0  0  -c 0  0  b  0  0  a  |                |
|                | 0 0 0 0  0  0  0  0  0  0  0  0  c  -b a  |                |
|                                                                             |
|          15                                 6                               |
|     1 : S   <----------------------------- S  : 2                           |
|                {1} | b  c  0  0  0  0  |                                    |
|                {1} | -a 0  c  0  0  0  |                                    |
|                {1} | 0  -a -b 0  0  0  |                                    |
|                {1} | a  0  0  -c 0  0  |                                    |
|                {1} | 0  a  0  b  0  0  |                                    |
|                {1} | 0  0  a  -a 0  0  |                                    |
|                {1} | b  0  0  0  -c 0  |                                    |
|                {1} | 0  b  0  0  b  0  |                                    |
|                {1} | 0  0  b  0  -a 0  |                                    |
|                {1} | c  0  0  0  0  -c |                                    |
|                {1} | 0  c  0  0  0  b  |                                    |
|                {1} | 0  0  c  0  0  -a |                                    |
|                {1} | 0  0  0  -b a  0  |                                    |
|                {1} | 0  0  0  -c 0  a  |                                    |
|                {1} | 0  0  0  0  -c b  |                                    |
|                                                                             |
|          6                  1                                               |
|     2 : S  <-------------- S  : 3                                           |
|               {2} | c  |                                                    |
|               {2} | -b |                                                    |
|               {2} | a  |                                                    |
|               {2} | a  |                                                    |
|               {2} | b  |                                                    |
|               {2} | c  |                                                    |
|                                                                             |
|o4 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|           20                                                                |
|--------- S   : 0                                                            |
|0  0  |                                                                      |
|0  0  |                                                                      |
|0  0  |                                                                      |
|0  0  |                                                                      |
|0  0  |                                                                      |
|0  0  |                                                                      |
|0  0  |                                                                      |
|0  0  |                                                                      |
|0  0  |                                                                      |
|0  0  |                                                                      |
|c  0  |                                                                      |
|-b 0  |                                                                      |
|0  -c |                                                                      |
|0  b  |                                                                      |
|a  -a |                                                                      |
+-----------------------------------------------------------------------------+
|i5 : assert isWellDefined D                                                  |
+-----------------------------------------------------------------------------+

The homology of this complex is $Hom(C, ZZ/101)$

+---------------------------------------+
|i6 : prune HH D == Hom(C, coker vars S)|
|                                       |
|o6 = true                              |
+---------------------------------------+

If one of the arguments is a module or a ring, it is considered as a complex
concentrated in homological degree 0.

+----------------------------------+
|i7 : E = Hom(C, S^2)              |
|                                  |
|      2      6      6      2      |
|o7 = S  <-- S  <-- S  <-- S       |
|                                  |
|     -3     -2     -1     0       |
|                                  |
|o7 : Complex                      |
+----------------------------------+
|i8 : prune HH E                   |
|                                  |
|o8 = cokernel {-3} | c b a 0 0 0 ||
|              {-3} | 0 0 0 c b a ||
|                                  |
|     -3                           |
|                                  |
|o8 : Complex                      |
+----------------------------------+

There is a simple relationship between Hom complexes and shifts.
Specifically, shifting the first argument is the same as the negative
shift of the result.  But shifting the second argument is only the same as the
positive shift of the result up to a sign.

+--------------------------------------------+
|i9 : Hom(C[3], C) == D[-3]                  |
|                                            |
|o9 = true                                   |
+--------------------------------------------+
|i10 : Hom(C, C[-2]) == D[-2]                |
|                                            |
|o10 = true                                  |
+--------------------------------------------+
|i11 : Hom(C, C[-3]) != D[-3]                |
|                                            |
|o11 = true                                  |
+--------------------------------------------+
|i12 : Hom(C, C[-3]) == complex(- dd^(D[-3]))|
|                                            |
|o12 = true                                  |
+--------------------------------------------+

Specific maps and morphisms between complexes can be obtained with
homomorphism(ComplexMap).

Because the Hom complex can be regarded as the total complex of a double
complex, each term comes with pairs of indices, labelling the summands.

+----------------------------------------+
|i13 : indices D_-1                      |
|                                        |
|o13 = {{0, -1}, {1, 0}, {2, 1}, {3, 2}} |
|                                        |
|o13 : List                              |
+----------------------------------------+
|i14 : components D_-1                   |
|                                        |
|           3   9   3                    |
|o14 = {0, S , S , S }                   |
|                                        |
|o14 : List                              |
+----------------------------------------+
|i15 : indices D_-2                      |
|                                        |
|o15 = {{0, -2}, {1, -1}, {2, 0}, {3, 1}}|
|                                        |
|o15 : List                              |
+----------------------------------------+
|i16 : components D_-2                   |
|                                        |
|              3   3                     |
|o16 = {0, 0, S , S }                    |
|                                        |
|o16 : List                              |
+----------------------------------------+

See also
========

  * homomorphism(ComplexMap) -- get the
    homomorphism from an element of Hom
  * homomorphism'(ComplexMap) -- get the
    element of Hom from a map of complexes
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes
  * indices (Macaulay2Doc) -- indices of a polynomial; also
    components for a direct sum
  * components (Macaulay2Doc) -- list the components of a
    direct sum
  * Hom(ComplexMap,ComplexMap) -- the
    map of complexes between Hom complexes

Ways to use this method:
========================

  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes
  * "Hom(Complex,Module)"
  * "Hom(Complex,Ring)"
  * "Hom(Module,Complex)"
  * "Hom(Ring,Complex)"

Hom(ComplexMap,ComplexMap) -- the map of complexes between Hom complexes
************************************************************************

Synopsis
========

  * Function: Hom (Macaulay2Doc),
  * Usage:
        h = Hom(f,g)
  * Inputs:
      * f, a map of complexes,
      * g, a map of complexes,
  * Outputs:
      * h, a map of complexes,

Description
===========

The maps $f : C \to D$ and $g : E \to F$ of chain complexes induces the map $h
= Hom(f,g) : Hom(D,E) \to Hom(C,F)$ defined by $\phi \mapsto g \phi f$.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..c];                                                       |
+-----------------------------------------------------------------------------+
|i2 : C = freeResolution coker vars S                                         |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : D = (freeResolution coker matrix{{a^2,a*b,b^3}})[-1]                    |
|                                                                             |
|      1      3      2                                                        |
|o3 = S  <-- S  <-- S                                                         |
|                                                                             |
|     1      2      3                                                         |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : f = randomComplexMap(D,C)                                               |
|                                                                             |
|                   1                                                         |
|o4 = 0 : 0 <----- S  : 0                                                     |
|              0                                                              |
|                                                                             |
|          1                                                3                 |
|     1 : S  <-------------------------------------------- S  : 1             |
|               | 24a-36b-30c -29a+19b+19c -10a-29b-8c |                      |
|                                                                             |
|          3                           3                                      |
|     2 : S  <----------------------- S  : 2                                  |
|               {2} | -22 -24 -16 |                                           |
|               {2} | -29 -38 39  |                                           |
|               {3} | 0   0   0   |                                           |
|                                                                             |
|          2                  1                                               |
|     3 : S  <-------------- S  : 3                                           |
|               {3} | 21 |                                                    |
|               {4} | 0  |                                                    |
|                                                                             |
|o4 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i5 : E = (dual C)[-3]                                                        |
|                                                                             |
|      1      3      3      1                                                 |
|o5 = S  <-- S  <-- S  <-- S                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o5 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i6 : F = (dual D)[-3]                                                        |
|                                                                             |
|      2      3      1                                                        |
|o6 = S  <-- S  <-- S                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o6 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i7 : g = randomComplexMap(F,E)                                               |
|                                                                             |
|          2                            1                                     |
|o7 = 0 : S  <------------------------ S  : 0                                 |
|               {-3} | 34          |                                          |
|               {-4} | 19a-47b-39c |                                          |
|                                                                             |
|          3                                                     3            |
|     1 : S  <------------------------------------------------- S  : 1        |
|               {-2} | -18          -47        45           |                 |
|               {-2} | -13          38         -34          |                 |
|               {-3} | -43a-15b-28c 2a+16b+22c -48a-47b+47c |                 |
|                                                                             |
|          1         3                                                        |
|     2 : S  <----- S  : 2                                                    |
|               0                                                             |
|                                                                             |
|                   1                                                         |
|     3 : 0 <----- S  : 3                                                     |
|              0                                                              |
|                                                                             |
|o7 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i8 : h = Hom(f,g)                                                            |
|                                                                             |
|           2                              2                                  |
|o8 = -3 : S  <-------------------------- S  : -3                             |
|                {-6} | 7           0 |                                       |
|                {-7} | -5a+23b-11c 0 |                                       |
|                                                                             |
|           9                                                                 |
|     -2 : S  <---------------------------------------------------------------|
|                {-5} | -41          24           0 0          0           0  |
|                {-6} | -14a+24b+50c -46a+50b+20c 0 0          0           0  |
|                {-5} | -8           21           0 0          0           0  |
|                {-6} | 49a+17b+27c  -15a-32b-33c 0 0          0           0  |
|                {-5} | -39          13           0 0          0           0  |
|                {-6} | -a+45b+18c   34a-15b-6c   0 0          0           0  |
|                {-5} | 0            0            0 26         23          36 |
|                {-5} | 0            0            0 30         -10         -7 |
|                {-6} | 0            0            0 6a-12b+18c 42a+33b-43c 2a+|
|                                                                             |
|           16                                                                |
|     -1 : S   <--------------------------------------------------------------|
|                 {-4} | 8a-12b-10c                    0            0         |
|                 {-5} | -49a2+6ab-25b2+9ac-14bc-42c2  0            0         |
|                 {-4} | 24a+40b+40c                   0            0         |
|                 {-5} | -46a2+7ab+16b2-23ac-18bc-34c2 0            0         |
|                 {-4} | -37a+24b+31c                  0            0         |
|                 {-5} | 12a2+20ab+50b2+36ac-8bc+9c2   0            0         |
|                 {-4} | 0                             -8           24        |
|                 {-4} | 0                             -17          -28       |
|                 {-5} | 0                             37a+27b+10c  -44a-49b+2|
|                 {-4} | 0                             28           17        |
|                 {-4} | 0                             9            -3        |
|                 {-5} | 0                             22a-44b-35c  -48a+20b-2|
|                 {-4} | 0                             -15          45        |
|                 {-4} | 0                             6            -2        |
|                 {-5} | 0                             -19a+38b+44c -32a+47b-4|
|                 {-3} | 0                             0            0         |
|                                                                             |
|          14                                                                 |
|     0 : S   <---------------------------------------------------------------|
|                {-3} | 0                              0                      |
|                {-4} | 0                              0                      |
|                {-3} | -28a+42b+35c                   -17a-25b-4c            |
|                {-3} | -9a-37b-14c                    3a+46b-29c             |
|                {-4} | -22a2-24ab+35b2+12ac+44bc+32c2 48a2+9ab+30b2-37ac+41bc|
|                {-3} | 17a-39b-39c                    50a+16b+16c            |
|                {-3} | -27a-45b-45c                   9a+15b+15c             |
|                {-4} | 35a2+22ab+18b2-5ac-9bc-27c2    43a2-22ab+b2+6ac+15bc+1|
|                {-3} | -22a+17b+43c                   -35a+50b-28c           |
|                {-3} | 29a-27b+3c                     24a+9b-c               |
|                {-4} | 26a2-17ab+31b2+18ac+23bc+22c2  -20a2-16ab+41b2-34ac+42|
|                {-2} | 0                              0                      |
|                {-2} | 0                              0                      |
|                {-2} | 0                              0                      |
|                                                                             |
|          6         6                                                        |
|     1 : S  <----- S  : 1                                                    |
|               0                                                             |
|                                                                             |
|          1         1                                                        |
|     2 : S  <----- S  : 2                                                    |
|               0                                                             |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                   9                                                         |
|----------------- S  : -2                                                    |
|        0 0 0 |                                                              |
|        0 0 0 |                                                              |
|        0 0 0 |                                                              |
|        0 0 0 |                                                              |
|        0 0 0 |                                                              |
|        0 0 0 |                                                              |
|        0 0 0 |                                                              |
|        0 0 0 |                                                              |
|23b-23c 0 0 0 |                                                              |
|                                                                             |
|                                                                             |
|---------------------------------------------------------------------------  |
|   0            0           0            0            0 0 0 0 0 0 0 0 0 |    |
|   0            0           0            0            0 0 0 0 0 0 0 0 0 |    |
|   0            0           0            0            0 0 0 0 0 0 0 0 0 |    |
|   0            0           0            0            0 0 0 0 0 0 0 0 0 |    |
|   0            0           0            0            0 0 0 0 0 0 0 0 0 |    |
|   0            0           0            0            0 0 0 0 0 0 0 0 0 |    |
|   20           17          50           8            0 0 0 0 0 0 0 0 0 |    |
|   41           -27         9            -24          0 0 0 0 0 0 0 0 0 |    |
|1c 46a+24b-24c  35a+31b+4c  43a+41b-32c  -22a+50b-50c 0 0 0 0 0 0 0 0 0 |    |
|   31           -23         -32          7            0 0 0 0 0 0 0 0 0 |    |
|   8            -11         -30          -21          0 0 0 0 0 0 0 0 0 |    |
|3c 41a+17b-17c  18a-36b-47c 25a-2b-28c   6a-32b+32c   0 0 0 0 0 0 0 0 0 |    |
|   -13          5           -15          38           0 0 0 0 0 0 0 0 0 |    |
|   39           -2          -33          -13          0 0 0 0 0 0 0 0 0 |    |
|9c -40a+45b-45c 40a+21b+19c -23a+18b+50c 47a-15b+15c  0 0 0 0 0 0 0 0 0 |    |
|   0            0           0            0            0 0 0 0 0 0 0 0 0 |    |
|                                                                             |
|                                                                  14         |
|---------------------------------------------------------------- S   : 0     |
|        0                              0 0 0 0 0 0 0 0 0 0 0 |               |
|        0                              0 0 0 0 0 0 0 0 0 0 0 |               |
|        -31a-4b-37c                    0 0 0 0 0 0 0 0 0 0 0 |               |
|        -8a+12b+10c                    0 0 0 0 0 0 0 0 0 0 0 |               |
|+47c2   -41a2-6ab-25b2+43ac+21bc+4c2   0 0 0 0 0 0 0 0 0 0 0 |               |
|        8a+47b+47c                     0 0 0 0 0 0 0 0 0 0 0 |               |
|        -24a-40b-40c                   0 0 0 0 0 0 0 0 0 0 0 |               |
|4c2     -22a2+47ab+16b2+48ac-16c2      0 0 0 0 0 0 0 0 0 0 0 |               |
|        -46a+8b+44c                    0 0 0 0 0 0 0 0 0 0 0 |               |
|        37a-24b-31c                    0 0 0 0 0 0 0 0 0 0 0 |               |
|bc+26c2 -25a2+44ab+50b2+15ac+23bc+28c2 0 0 0 0 0 0 0 0 0 0 0 |               |
|        0                              0 0 0 0 0 0 0 0 0 0 0 |               |
|        0                              0 0 0 0 0 0 0 0 0 0 0 |               |
|        0                              0 0 0 0 0 0 0 0 0 0 0 |               |
|-----------------------------------------------------------------------------|
| 16                                                                          |
|S   : -1                                                                     |
+-----------------------------------------------------------------------------+
|i9 : assert isWellDefined h                                                  |
+-----------------------------------------------------------------------------+
|i10 : assert(source h === Hom(D,E))                                          |
+-----------------------------------------------------------------------------+
|i11 : assert(target h === Hom(C,F))                                          |
+-----------------------------------------------------------------------------+

We illustrate the defining property of the map $h$ on a random element $\phi$
in degree zero.

+-----------------------------------------------------------------------------+
|i12 : e = randomComplexMap(source h, complex(S^1))                           |
|                                                                             |
|           14                                                                |
|o12 = 0 : S   <--------------------------------------------------------------|
|                 {-2} | 19a2-16ab+15b2+7ac-23bc+39c2                         |
|                 {-2} | 43a2-17ab+48b2-11ac+36bc+35c2                        |
|                 {-2} | 11a2-38ab+40b2+33ac+11bc+46c2                        |
|                 {-3} | -28a3+a2b+22ab2-7b3-3a2c-47abc+2b2c-23ac2+29bc2-47c3 |
|                 {-3} | 15a3-37a2b-10ab2+39b3-13a2c+30abc+27b2c-18ac2-22bc2+3|
|                 {-3} | -9a3-32a2b+24ab2-15b3-20a2c-30abc+39b2c-48ac2+33c3   |
|                 {-3} | -49a3-33a2b+17ab2-39b3-19a2c-20abc+36b2c+44ac2+9bc2-3|
|                 {-3} | 4a3+13a2b+22ab2-8b3-26a2c-49abc+43b2c-11ac2-8bc2+36c3|
|                 {-3} | -3a3-22a2b+41ab2-6b3-30a2c+16abc+35b2c-28ac2-9bc2-35c|
|                 {-4} | 6a4+40a3b-31a2b2-41ab3+30b4+3a3c+25a2bc-49ab2c-47b3c-|
|                 {-4} | -35a4-31a3b-31a2b2-48ab3-49b4-39a3c-48a2bc+30ab2c+28b|
|                 {-4} | 40a4-22a3b+7a2b2-17ab3+8b4+10a3c+30a2bc-13ab2c+8b3c+1|
|                 {-3} | 49a3-18a2b+23ab2+18b3+42a2c-28abc-16b2c+15ac2-46bc2+1|
|                 {-4} | -18a4+27a3b+23a2b2+44ab3-21a3c-37a2bc-39ab2c-47b3c-23|
|                                                                             |
|o12 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                            1                                |
|------------------------------------------ S  : 0                            |
|                                       |                                     |
|                                       |                                     |
|                                       |                                     |
|                                       |                                     |
|2c3                                    |                                     |
|                                       |                                     |
|9c3                                    |                                     |
|                                       |                                     |
|3                                      |                                     |
|2a2c2-13abc2+27b2c2+4ac3-40bc3+37c4    |                                     |
|3c-29a2c2-37abc2-18b2c2+47ac3+46bc3+c4 |                                     |
|3a2c2+3abc2-29b2c2-41ac3+30bc3-46c4    |                                     |
|2c3                                    |                                     |
|a2c2+20abc2-28b2c2+19ac3+47bc3-28c4    |                                     |
+-----------------------------------------------------------------------------+
|i13 : phi = homomorphism e                                                   |
|                                                                             |
|           3                                              1                  |
|o13 = 1 : S  <------------------------------------------ S  : 1              |
|                {-2} | 19a2-16ab+15b2+7ac-23bc+39c2  |                       |
|                {-2} | 43a2-17ab+48b2-11ac+36bc+35c2 |                       |
|                {-2} | 11a2-38ab+40b2+33ac+11bc+46c2 |                       |
|                                                                             |
|           3                                                                 |
|      2 : S  <---------------------------------------------------------------|
|                {-1} | -28a3+a2b+22ab2-7b3-3a2c-47abc+2b2c-23ac2+29bc2-47c3  |
|                {-1} | 15a3-37a2b-10ab2+39b3-13a2c+30abc+27b2c-18ac2-22bc2+32|
|                {-1} | -9a3-32a2b+24ab2-15b3-20a2c-30abc+39b2c-48ac2+33c3    |
|                                                                             |
|           1                                                                 |
|      3 : S  <---------------------------------------------------------------|
|                | 49a3-18a2b+23ab2+18b3+42a2c-28abc-16b2c+15ac2-46bc2+12c3 -1|
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|   -49a3-33a2b+17ab2-39b3-19a2c-20abc+36b2c+44ac2+9bc2-39c3 6a4+40a3b-31a2b2-|
|c3 4a3+13a2b+22ab2-8b3-26a2c-49abc+43b2c-11ac2-8bc2+36c3    -35a4-31a3b-31a2b|
|   -3a3-22a2b+41ab2-6b3-30a2c+16abc+35b2c-28ac2-9bc2-35c3   40a4-22a3b+7a2b2-|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|8a4+27a3b+23a2b2+44ab3-21a3c-37a2bc-39ab2c-47b3c-23a2c2+20abc2-28b2c2+19ac3+4|
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|41ab3+30b4+3a3c+25a2bc-49ab2c-47b3c-2a2c2-13abc2+27b2c2+4ac3-40bc3+37c4    | |
|2-48ab3-49b4-39a3c-48a2bc+30ab2c+28b3c-29a2c2-37abc2-18b2c2+47ac3+46bc3+c4 | |
|17ab3+8b4+10a3c+30a2bc-13ab2c+8b3c+13a2c2+3abc2-29b2c2-41ac3+30bc3-46c4    | |
|                                                                             |
|               2                                                             |
|------------- S  : 3                                                         |
|7bc3-28c4 |                                                                  |
|-----------------------------------------------------------------------------|
|   3                                                                         |
|- S  : 2                                                                     |
+-----------------------------------------------------------------------------+
|i14 : psi = homomorphism'(g * phi * f)                                       |
|                                                                             |
|           14                                                                |
|o14 = 0 : S   <--------------------------------------------------------------|
|                 {-3} | 0                                                    |
|                 {-4} | 0                                                    |
|                 {-3} | 12a3-22a2b-46ab2-23b3-37a2c+32abc-27b2c-5ac2+31bc2+28|
|                 {-3} | -29a3-14a2b-48ab2+12b3-46a2c-7abc+23b2c+38ac2+6bc2+10|
|                 {-4} | -17a4+50a3b+49a2b2+15ab3-45b4+4a3c+22a2bc+47ab2c+34b3|
|                 {-3} | 36a3+48a2b+26ab2+43b3-6a2c-47abc+13b2c+45ac2-41bc2-11|
|                 {-3} | 14a3+36a2b+42ab2-40b3-13a2c-43abc-16b2c-6ac2-16bc2-40|
|                 {-4} | 50a4+39a3b+a2b2+39ab3+49b4+40a3c-35a2bc-35ab2c-21b3c+|
|                 {-3} | -5a3+4a2b-24ab2+46b3+22a2c+22abc+33b2c-17ac2-45bc2-6c|
|                 {-3} | -30a3-42a2b+16ab2-24b3+25a2c-36abc+44b2c-45ac2+35bc2-|
|                 {-4} | -35a4+44a3b+2a2b2-33ab3-11b4+36a3c+11a2bc+7ab2c+49b3c|
|                 {-2} | 0                                                    |
|                 {-2} | 0                                                    |
|                 {-2} | 0                                                    |
|                                                                             |
|o14 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                            1                                |
|------------------------------------------ S  : 0                            |
|                                       |                                     |
|                                       |                                     |
|c3                                     |                                     |
|c3                                     |                                     |
|c-16a2c2-16abc2+8b2c2-20ac3-34bc3+47c4 |                                     |
|c3                                     |                                     |
|c3                                     |                                     |
|22a2c2+47abc2+29b2c2+39ac3+12bc3+14c4  |                                     |
|3                                      |                                     |
|31c3                                   |                                     |
|-17a2c2+49abc2-10b2c2-16ac3+22bc3+26c4 |                                     |
|                                       |                                     |
|                                       |                                     |
|                                       |                                     |
+-----------------------------------------------------------------------------+
|i15 : assert(h*e == psi)                                                     |
+-----------------------------------------------------------------------------+

If either of the arguments is a Complex, that argument is
understood to be the identity map on that complex.

+---------------------------------------+
|i16 : assert(Hom(f, C) == Hom(f, id_C))|
+---------------------------------------+
|i17 : assert(Hom(C, f) == Hom(id_C, f))|
+---------------------------------------+

If either of the arguments is a Module (Macaulay2Doc), or a
Ring (Macaulay2Doc), that argument is understood to be the identity map
on the complex having a unique non-zero term in in homological degree 0.  The
ring must be the underlying ring of the map of complexes.

+---------------------------------------------------+
|i18 : assert(Hom(f, S) == Hom(f, id_(complex S)))  |
+---------------------------------------------------+
|i19 : assert(Hom(S, f) == Hom(id_(complex S), f))  |
+---------------------------------------------------+
|i20 : M = S^1/(a^2, b^2, c^2)                      |
|                                                   |
|o20 = cokernel | a2 b2 c2 |                        |
|                                                   |
|                             1                     |
|o20 : S-module, quotient of S                      |
+---------------------------------------------------+
|i21 : assert(Hom(f, M) == Hom(f, id _ (complex M)))|
+---------------------------------------------------+
|i22 : assert(Hom(M, f) == Hom(id _ (complex M), f))|
+---------------------------------------------------+

If either of the arguments is a Matrix (Macaulay2Doc), that
argument is understood to be a map of complexes whose source and target have a
unique non-zero entry in homological degree 0.

+-----------------------------------------------------------------------------+
|i23 : m = vars S;                                                            |
|                                                                             |
|              1       3                                                      |
|o23 : Matrix S  <--- S                                                       |
+-----------------------------------------------------------------------------+
|i24 : h1 = Hom(f, m)                                                         |
|                                                                             |
|            1                                  6                             |
|o24 = -3 : S  <------------------------------ S  : -3                        |
|                 {-3} | 21a 21b 21c 0 0 0 |                                  |
|                                                                             |
|            3                                                    9           |
|      -2 : S  <------------------------------------------------ S  : -2      |
|                 {-2} | -22a -22b -22c -29a -29b -29c 0 0 0 |                |
|                 {-2} | -24a -24b -24c -38a -38b -38c 0 0 0 |                |
|                 {-2} | -16a -16b -16c 39a  39b  39c  0 0 0 |                |
|                                                                             |
|            3                                                                |
|      -1 : S  <------------------------------------------------------------  |
|                 {-1} | 24a2-36ab-30ac  24ab-36b2-30bc  24ac-36bc-30c2  |    |
|                 {-1} | -29a2+19ab+19ac -29ab+19b2+19bc -29ac+19bc+19c2 |    |
|                 {-1} | -10a2-29ab-8ac  -10ab-29b2-8bc  -10ac-29bc-8c2  |    |
|                                                                             |
|o24 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
| 3                                                                           |
|S  : -1                                                                      |
+-----------------------------------------------------------------------------+
|i25 : assert(h1 == Hom(f, map(complex target m, complex source m, i -> m)))  |
+-----------------------------------------------------------------------------+
|i26 : m = vars S;                                                            |
|                                                                             |
|              1       3                                                      |
|o26 : Matrix S  <--- S                                                       |
+-----------------------------------------------------------------------------+
|i27 : h2 = Hom(m, f)                                                         |
|                                                                             |
|           3                                                              3  |
|o27 = 1 : S  <---------------------------------------------------------- S  :|
|                {-1} | 24a2-36ab-30ac -29a2+19ab+19ac -10a2-29ab-8ac |       |
|                {-1} | 24ab-36b2-30bc -29ab+19b2+19bc -10ab-29b2-8bc |       |
|                {-1} | 24ac-36bc-30c2 -29ac+19bc+19c2 -10ac-29bc-8c2 |       |
|                                                                             |
|           9                              3                                  |
|      2 : S  <-------------------------- S  : 2                              |
|                {1} | -22a -24a -16a |                                       |
|                {1} | -29a -38a 39a  |                                       |
|                {2} | 0    0    0    |                                       |
|                {1} | -22b -24b -16b |                                       |
|                {1} | -29b -38b 39b  |                                       |
|                {2} | 0    0    0    |                                       |
|                {1} | -22c -24c -16c |                                       |
|                {1} | -29c -38c 39c  |                                       |
|                {2} | 0    0    0    |                                       |
|                                                                             |
|           6                   1                                             |
|      3 : S  <--------------- S  : 3                                         |
|                {2} | 21a |                                                  |
|                {3} | 0   |                                                  |
|                {2} | 21b |                                                  |
|                {3} | 0   |                                                  |
|                {2} | 21c |                                                  |
|                {3} | 0   |                                                  |
|                                                                             |
|o27 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|1                                                                            |
+-----------------------------------------------------------------------------+
|i28 : assert(h2 == Hom(map(complex target m, complex source m, i -> m), f))  |
+-----------------------------------------------------------------------------+

XXX write this text after writing doc for homomorphism and homomorphism'.

+-----------------------------------------------------------------------------+
|i29 : e = randomComplexMap(source h, complex(S^1, Base => -1))               |
|                                                                             |
|            16                                                               |
|o29 = -1 : S   <-------------------------------------------------------------|
|                  {-3} | 6a3-9a2b+28ab2+5b3-33a2c-29abc-37b2c+26ac2-33bc2-28c|
|                  {-4} | 42a4+44a3b+4a2b2-20ab3-4b4+30a3c+22a2bc-13ab2c+12b3c|
|                  {-4} | 20a4-26a3b+16a2b2+28ab3-4b4+33a3c+10a2bc-6ab2c-14b3c|
|                  {-4} | -5a4-16a3b-39a2b2-32ab3-45b4-35a3c-4a2bc-23ab2c+18b3|
|                  {-4} | 8a4+42a3b+5a2b2+28ab3-46b4+49a3c-38a2bc-33ab2c+2b3c-|
|                  {-4} | -50a4-29a3b-49a2b2+28ab3+42b4-26a3c+34a2bc+36ab2c+37|
|                  {-4} | -31a4-49a3b+43a2b2-40ab3-29b4-a3c+48a2bc-47ab2c-44b3|
|                  {-5} | -4a5-2a4b-8a3b2+38a2b3-42ab4-31b5+34a4c+27a3bc+37a2b|
|                  {-5} | 6a5-43a4b-50a3b2+5a2b3+10ab4-3b5-27a4c-6a3bc-21a2b2c|
|                  {-5} | 10a5+10a4b-42a3b2-39a2b3-10ab4+14b5+34a4c+34a3bc-40a|
|                  {-4} | 49a4-41a3b+14a2b2-36ab3-29b4+38a3c+6a2bc-40ab2c+21b3|
|                  {-4} | 4a4+45a3b+20a2b2+41ab3-41b4-39a3c+25a2bc+47ab2c+46b3|
|                  {-4} | 13a4+32a3b-41a2b2-34ab3+44b4-26a3c-17a2bc-24b3c-17a2|
|                  {-5} | -37a5-41a4b+45a3b2-46a2b3+49ab4+46b5-12a4c+22a3bc+4a|
|                  {-5} | -47a5+2a4b-49a2b3+24ab4+16b5-50a4c+9a3bc+20a2b2c-38a|
|                  {-5} | -36a5+13a4b+21a3b2+11ab4-43b5-42a4c-50a3bc+43a2b2c-2|
|                                                                             |
|o29 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|3                                                                            |
|+5a2c2-29abc2+3b2c2+15ac3+9bc3-2c4                                           |
|+31a2c2+21abc2-33b2c2-30ac3-42bc3-44c4                                       |
|c-24a2c2-18abc2-28b2c2+27ac3+42bc3-11c4                                      |
|26a2c2+9abc2-19b2c2-7ac3+43bc3-28c4                                          |
|b3c+31a2c2-40abc2+34b2c2+45ac3+5bc3+16c4                                     |
|c+8a2c2+19abc2-42b2c2-45ac3-17bc3-23c4                                       |
|2c+24ab3c+37b4c+7a3c2-24a2bc2-24ab2c2+4b3c2+25a2c3-47abc3+5b2c3+12ac4+36bc4-1|
|-15ab3c-28b4c+43a3c2+23a2bc2+47ab2c2-50b3c2-47a2c3+15abc3+17b2c3-11ac4-30bc4-|
|2b2c-37ab3c-37b4c-44a3c2-29a2bc2-36ab2c2+10b3c2+50a2c3+32abc3+33b2c3-3ac4+26b|
|c+50a2c2-33abc2+46b2c2-19ac3+10bc3-16c4                                      |
|c+11a2c2-17abc2-35b2c2-47ac3-39bc3+33c4                                      |
|c2+39abc2+15b2c2-35ac3-20bc3+28c4                                            |
|2b2c-20ab3c+26b4c-49a3c2+22a2bc2-45ab2c2-13b3c2+7a2c3+36abc3+29b2c3-43ac4+10b|
|b3c+16b4c-49a3c2-49a2bc2+41ab2c2+22b3c2-34a2c3+15abc3+17b2c3+10ac4-8bc4-41c5 |
|9ab3c+48b4c+35a3c2+47a2bc2-18ab2c2+24b3c2-16a2c3-3abc3-23b2c3+42ac4-46bc4-36c|
|-----------------------------------------------------------------------------|
|             1                                                               |
|----------- S  : -1                                                          |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|6c5     |                                                                    |
|37c5    |                                                                    |
|c4-18c5 |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|c4+3c5  |                                                                    |
|        |                                                                    |
|5       |                                                                    |
+-----------------------------------------------------------------------------+
|i30 : phi = homomorphism e                                                   |
|                                                                             |
|           1                                                                 |
|o30 = 0 : S  <---------------------------------------------------------------|
|                {-3} | 6a3-9a2b+28ab2+5b3-33a2c-29abc-37b2c+26ac2-33bc2-28c3 |
|                                                                             |
|           3                                                                 |
|      1 : S  <---------------------------------------------------------------|
|                {-2} | 42a4+44a3b+4a2b2-20ab3-4b4+30a3c+22a2bc-13ab2c+12b3c+5|
|                {-2} | 20a4-26a3b+16a2b2+28ab3-4b4+33a3c+10a2bc-6ab2c-14b3c+3|
|                {-2} | -5a4-16a3b-39a2b2-32ab3-45b4-35a3c-4a2bc-23ab2c+18b3c-|
|                                                                             |
|           3                                                                 |
|      2 : S  <---------------------------------------------------------------|
|                {-1} | 49a4-41a3b+14a2b2-36ab3-29b4+38a3c+6a2bc-40ab2c+21b3c+|
|                {-1} | 4a4+45a3b+20a2b2+41ab3-41b4-39a3c+25a2bc+47ab2c+46b3c+|
|                {-1} | 13a4+32a3b-41a2b2-34ab3+44b4-26a3c-17a2bc-24b3c-17a2c2|
|                                                                             |
|o30 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|     1                                                                       |
|--- S  : 1                                                                   |
||                                                                            |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|a2c2-29abc2+3b2c2+15ac3+9bc3-2c4      8a4+42a3b+5a2b2+28ab3-46b4+49a3c-38a2bc|
|1a2c2+21abc2-33b2c2-30ac3-42bc3-44c4  -50a4-29a3b-49a2b2+28ab3+42b4-26a3c+34a|
|24a2c2-18abc2-28b2c2+27ac3+42bc3-11c4 -31a4-49a3b+43a2b2-40ab3-29b4-a3c+48a2b|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|50a2c2-33abc2+46b2c2-19ac3+10bc3-16c4 -37a5-41a4b+45a3b2-46a2b3+49ab4+46b5-12|
|11a2c2-17abc2-35b2c2-47ac3-39bc3+33c4 -47a5+2a4b-49a2b3+24ab4+16b5-50a4c+9a3b|
|+39abc2+15b2c2-35ac3-20bc3+28c4       -36a5+13a4b+21a3b2+11ab4-43b5-42a4c-50a|
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|-33ab2c+2b3c-26a2c2+9abc2-19b2c2-7ac3+43bc3-28c4      -4a5-2a4b-8a3b2+38a2b3-|
|2bc+36ab2c+37b3c+31a2c2-40abc2+34b2c2+45ac3+5bc3+16c4 6a5-43a4b-50a3b2+5a2b3+|
|c-47ab2c-44b3c+8a2c2+19abc2-42b2c2-45ac3-17bc3-23c4   10a5+10a4b-42a3b2-39a2b|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|a4c+22a3bc+4a2b2c-20ab3c+26b4c-49a3c2+22a2bc2-45ab2c2-13b3c2+7a2c3+36abc3+29b|
|c+20a2b2c-38ab3c+16b4c-49a3c2-49a2bc2+41ab2c2+22b3c2-34a2c3+15abc3+17b2c3+10a|
|3bc+43a2b2c-29ab3c+48b4c+35a3c2+47a2bc2-18ab2c2+24b3c2-16a2c3-3abc3-23b2c3+42|
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|42ab4-31b5+34a4c+27a3bc+37a2b2c+24ab3c+37b4c+7a3c2-24a2bc2-24ab2c2+4b3c2+25a2|
|10ab4-3b5-27a4c-6a3bc-21a2b2c-15ab3c-28b4c+43a3c2+23a2bc2+47ab2c2-50b3c2-47a2|
|3-10ab4+14b5+34a4c+34a3bc-40a2b2c-37ab3c-37b4c-44a3c2-29a2bc2-36ab2c2+10b3c2+|
|                                                                             |
|                         2                                                   |
|----------------------- S  : 3                                               |
|2c3-43ac4+10bc4+3c5 |                                                        |
|c4-8bc4-41c5        |                                                        |
|ac4-46bc4-36c5      |                                                        |
|-----------------------------------------------------------------------------|
|                                          3                                  |
|---------------------------------------- S  : 2                              |
|c3-47abc3+5b2c3+12ac4+36bc4-16c5     |                                       |
|c3+15abc3+17b2c3-11ac4-30bc4-37c5    |                                       |
|50a2c3+32abc3+33b2c3-3ac4+26bc4-18c5 |                                       |
+-----------------------------------------------------------------------------+
|i31 : assert(degree phi == -1)                                               |
+-----------------------------------------------------------------------------+
|i32 : psi = homomorphism'(g * phi * f)                                       |
|                                                                             |
|            16                                                               |
|o32 = -1 : S   <-------------------------------------------------------------|
|                  {-4} | 48a4-43a3b+29a2b2+7ab3+41b4-21a3c-49a2bc-26ab2c-10b3|
|                  {-5} | 9a5-28a4b+40a3b2+47a2b3+37ab4-24b5-46a4c+48a3bc+14a2|
|                  {-4} | 43a4+24a3b+9a2b2+28ab3-2b4-47a3c+48a2bc-19ab2c+33b3c|
|                  {-5} | 27a5-49a4b-43a3b2+24a2b3-22ab4-21b5-34a4c-10a3bc-16a|
|                  {-4} | -20a4-28a3b-40a2b2-18ab3+19b4-7a3c+2a2bc+26ab2c-26b3|
|                  {-5} | -29a5+12a4b-49a3b2-32a2b3-15ab4+48b5+22a4c+34a3bc+22|
|                  {-4} | -43a4-25a2b2+31ab3+21b4-17a3c+8a2bc-41ab2c+46b3c-18a|
|                  {-4} | 13a4+14a3b+14a2b2+13ab3+45b4+42a3c-32a2bc-29ab2c+39b|
|                  {-5} | -37a5+19a4b-33a3b2+21a2b3-34ab4-25b5-19a4c+28a3bc-9a|
|                  {-4} | 35a4+14a3b+20a2b2+33ab3-44b4+14a3c-24a2bc+18ab2c+27b|
|                  {-4} | 18a4-35a3b-14a2b2-20ab3-24b4-49a3c+41a2bc-13ab2c-15b|
|                  {-5} | -18a5-38a4b-13a3b2+32a2b3+25ab4+13b5-7a4c+19a3bc-28a|
|                  {-4} | 48a4-11a3b+26a2b2-26ab3+18b4-34a3c-17a2bc-45ab2c-29b|
|                  {-4} | 34a4-10a3b+24a2b2+35ab3+39b4+27a3c+3a2bc+41ab2c+48b3|
|                  {-5} | -13a5-3a4b-6a3b2+16a2b3-44ab4-19b5-41a4c-25a3bc-8a2b|
|                  {-3} | 0                                                   |
|                                                                             |
|o32 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|c+33a2c2+17abc2-42b2c2+21ac3-41bc3-23c4                                      |
|b2c-46ab3c+47b4c-5a3c2+29a2bc2-32ab2c2+22b3c2-38a2c3-15abc3-11b2c3-31ac4-40bc|
|+11a2c2-3abc2+28b2c2-36ac3-16bc3-9c4                                         |
|2b2c-29ab3c+25b4c-35a3c2+35a2bc2-32b3c2-6a2c3-30abc3-10b2c3-38ac4+10bc4+43c5 |
|c+35a2c2+37abc2-20b2c2+24ac3+22bc3+41c4                                      |
|a2b2c-12ab3c+29b4c-14a3c2-30a2bc2-6ab2c2+4b3c2+5abc3+46b2c3+34ac4+28bc4-50c5 |
|2c2-6abc2-32b2c2-44ac3-bc3-9c4                                               |
|3c-37a2c2+27abc2+37b2c2+33ac3+17bc3+45c4                                     |
|2b2c+40ab3c-18b4c-34a3c2+31a2bc2-4ab2c2+48b3c2+23a2c3-33abc3-7b2c3+12ac4+43bc|
|3c-11a2c2-9abc2+33b2c2-39ac3-24bc3+38c4                                      |
|3c-42a2c2+32abc2-27b2c2+12ac3-26bc3+34c4                                     |
|2b2c+50ab3c-3b4c+20a3c2-50a2bc2+6ab2c2-28b3c2-a2c3+abc3+9b2c3+23ac4-15bc4-13c|
|3c+28a2c2-49abc2-34b2c2-3ac3-47bc3-31c4                                      |
|c-23a2c2+36abc2-31b2c2+14ac3+29bc3-21c4                                      |
|2c-31ab3c-36b4c-4a3c2+32a2bc2+6ab2c2-20b3c2-50a2c3-17abc3-28b2c3-43ac4-6bc4-3|
|                                                                             |
|-----------------------------------------------------------------------------|
|            1                                                                |
|---------- S  : 0                                                            |
|       |                                                                     |
|4-36c5 |                                                                     |
|       |                                                                     |
|       |                                                                     |
|       |                                                                     |
|       |                                                                     |
|       |                                                                     |
|       |                                                                     |
|4+48c5 |                                                                     |
|       |                                                                     |
|       |                                                                     |
|5      |                                                                     |
|       |                                                                     |
|       |                                                                     |
|9c5    |                                                                     |
|       |                                                                     |
+-----------------------------------------------------------------------------+
|i33 : i = map(complex S^1, source e, id_(source e), Degree => 1)             |
|                                                                             |
|           1             1                                                   |
|o33 = 0 : S  <--------- S  : -1                                              |
|                | 1 |                                                        |
|                                                                             |
|o33 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i34 : assert(h*e == psi*i)                                                   |
+-----------------------------------------------------------------------------+
|i35 : assert((degree h, degree e, degree psi, degree i) === (0, 0, -1, 1))   |
+-----------------------------------------------------------------------------+

This routine is functorial.

+-----------------------------------------------------------------------------+
|i36 : D' = (freeResolution coker matrix{{a^2,a*b,c^3}})[-1]                  |
|                                                                             |
|       1      3      3      1                                                |
|o36 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      1      2      3      4                                                 |
|                                                                             |
|o36 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i37 : f' = randomComplexMap(D', D)                                           |
|                                                                             |
|           1              1                                                  |
|o37 = 1 : S  <---------- S  : 1                                              |
|                | 50 |                                                       |
|                                                                             |
|           3                                 3                               |
|      2 : S  <----------------------------- S  : 2                           |
|                {2} | 10 29 44a-44b-24c |                                    |
|                {2} | -2 37 -33a-6b-47c |                                    |
|                {3} | 0  0  -46         |                                    |
|                                                                             |
|           3                               2                                 |
|      3 : S  <--------------------------- S  : 3                             |
|                {3} | -27 38a+43b-33c |                                      |
|                {5} | 0   0           |                                      |
|                {5} | 0   0           |                                      |
|                                                                             |
|o37 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i38 : Hom(f' * f, g) == Hom(f, id_F) * Hom(f', g)                            |
|                                                                             |
|o38 = true                                                                   |
+-----------------------------------------------------------------------------+
|i39 : Hom(f' * f, g) == Hom(f, g) * Hom(f', id_E)                            |
|                                                                             |
|o39 = true                                                                   |
+-----------------------------------------------------------------------------+
|i40 : F' = dual (freeResolution coker matrix{{a^2,a*b,a*c,b^3}})[-3]         |
|                                                                             |
|       1      4      4      1                                                |
|o40 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o40 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i41 : g' = randomComplexMap(F', F)                                           |
|                                                                             |
|           1                                2                                |
|o41 = 0 : S  <---------------------------- S  : 0                            |
|                {-4} | 25a+15b-42c -25 |                                     |
|                                                                             |
|           4                                                                 |
|      1 : S  <---------------------------------------------------------------|
|                {-3} | -10a+25b+24c              -26a-17b-14c                |
|                {-3} | -27a-28b-24c              18a-12b-12c                 |
|                {-3} | -30a+43b-25c              2a-25b-46c                  |
|                {-4} | 7a2+7ab+37b2+9ac-4bc+30c2 27a2-44ab+20b2-40ac+18bc-32c|
|                                                                             |
|           4                                                                 |
|      2 : S  <---------------------------------------------------------------|
|                {-2} | 39a2-6ab+18b2-18ac+37bc-17c2                          |
|                {-2} | 34a2+7ab+36b2-44ac+48bc+46c2                          |
|                {-2} | 38a2+27ab+12b2-5ac+39bc-41c2                          |
|                {-3} | 17a3-40a2b+28ab2-33b3+35a2c+17abc-21b2c+23ac2+39bc2-43|
|                                                                             |
|o41 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                    3                                                        |
|------------------ S  : 1                                                    |
|  -3           |                                                             |
|  21           |                                                             |
|  38           |                                                             |
|2 -48a-33b-34c |                                                             |
|                                                                             |
|        1                                                                    |
|------ S  : 2                                                                |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|c3 |                                                                         |
+-----------------------------------------------------------------------------+
|i42 : Hom(f, g' * g) == Hom(f, g') * Hom(id_D, g)                            |
|                                                                             |
|o42 = true                                                                   |
+-----------------------------------------------------------------------------+
|i43 : Hom(f, g' * g) == Hom(id_C, g') * Hom(f, g)                            |
|                                                                             |
|o43 = true                                                                   |
+-----------------------------------------------------------------------------+

See also
========

  * homomorphism(ComplexMap) -- get the
    homomorphism from an element of Hom
  * homomorphism'(ComplexMap) -- get the
    element of Hom from a map of complexes
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes

Ways to use this method:
========================

  * "Hom(Complex,ComplexMap)"
  * "Hom(Complex,Matrix)"
  * "Hom(ComplexMap,Complex)"
  * Hom(ComplexMap,ComplexMap) -- the
    map of complexes between Hom complexes
  * "Hom(ComplexMap,Matrix)"
  * "Hom(ComplexMap,Module)"
  * "Hom(ComplexMap,Ring)"
  * "Hom(Matrix,Complex)"
  * "Hom(Matrix,ComplexMap)"
  * "Hom(Module,ComplexMap)"
  * "Hom(Ring,ComplexMap)"

homomorphism'(ComplexMap) -- get the element of Hom from a map of complexes
***************************************************************************

Synopsis
========

  * Function: homomorphism' (Macaulay2Doc),
  * Usage:
        f = homomorphism g
  * Inputs:
      * g, a map of complexes, from $C$ to $D$
  * Outputs:
      * f, a map of complexes, a map of the form $f : R^1
        \to Hom(C, D)$, where $R$ is the underlying ring of these complexes

Description
===========

As a first example, consider two Koszul complexes $C$ and $D$. From a random
map $f : R^1 \to Hom(C, D)$, we construct the corresponding map of chain
complexes $g : C \to D$.

+----------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c]                                                |
|                                                                      |
|o1 = R                                                                |
|                                                                      |
|o1 : PolynomialRing                                                   |
+----------------------------------------------------------------------+
|i2 : C = freeResolution ideal"a,b,c"                                  |
|                                                                      |
|      1      3      3      1                                          |
|o2 = R  <-- R  <-- R  <-- R                                           |
|                                                                      |
|     0      1      2      3                                           |
|                                                                      |
|o2 : Complex                                                          |
+----------------------------------------------------------------------+
|i3 : D = freeResolution ideal"a2,b2,c2"                               |
|                                                                      |
|      1      3      3      1                                          |
|o3 = R  <-- R  <-- R  <-- R                                           |
|                                                                      |
|     0      1      2      3                                           |
|                                                                      |
|o3 : Complex                                                          |
+----------------------------------------------------------------------+
|i4 : g = randomComplexMap(D, C, InternalDegree => 2)                  |
|                                                                      |
|          1                                         1                 |
|o4 = 0 : R  <------------------------------------- R  : 0             |
|               | 24a2-36ab-29b2-30ac+19bc+19c2 |                      |
|                                                                      |
|          3                                                      3    |
|     1 : R  <-------------------------------------------------- R  : 1|
|               {2} | -10a-29b-8c  21a+34b+19c  -28a-47b+38c |         |
|               {2} | -22a-29b-24c -47a-39b-18c 2a+16b+22c   |         |
|               {2} | -38a-16b+39c -13a-43b-15c 45a-34b-48c  |         |
|                                                                      |
|          3                           3                               |
|     2 : R  <----------------------- R  : 2                           |
|               {4} | -47 -16 -23 |                                    |
|               {4} | 47  7   39  |                                    |
|               {4} | 19  15  43  |                                    |
|                                                                      |
|          1         1                                                 |
|     3 : R  <----- R  : 3                                             |
|               0                                                      |
|                                                                      |
|o4 : ComplexMap                                                       |
+----------------------------------------------------------------------+
|i5 : isWellDefined g                                                  |
|                                                                      |
|o5 = true                                                             |
+----------------------------------------------------------------------+
|i6 : f = homomorphism' g                                              |
|                                                                      |
|          20                                             1            |
|o6 = 0 : R   <----------------------------------------- R  : 0        |
|                {0} | 24a2-36ab-29b2-30ac+19bc+19c2 |                 |
|                {1} | -10a-29b-8c                   |                 |
|                {1} | -22a-29b-24c                  |                 |
|                {1} | -38a-16b+39c                  |                 |
|                {1} | 21a+34b+19c                   |                 |
|                {1} | -47a-39b-18c                  |                 |
|                {1} | -13a-43b-15c                  |                 |
|                {1} | -28a-47b+38c                  |                 |
|                {1} | 2a+16b+22c                    |                 |
|                {1} | 45a-34b-48c                   |                 |
|                {2} | -47                           |                 |
|                {2} | 47                            |                 |
|                {2} | 19                            |                 |
|                {2} | -16                           |                 |
|                {2} | 7                             |                 |
|                {2} | 15                            |                 |
|                {2} | -23                           |                 |
|                {2} | 39                            |                 |
|                {2} | 43                            |                 |
|                {3} | 0                             |                 |
|                                                                      |
|o6 : ComplexMap                                                       |
+----------------------------------------------------------------------+
|i7 : isWellDefined f                                                  |
|                                                                      |
|o7 = true                                                             |
+----------------------------------------------------------------------+

The map $g : C \to D$ corresponding to a random map into $Hom(C,D)$ does not
generally commute with the differentials.  However, if the element of
$Hom(C,D)$ is a cycle, then the corresponding map does commute.

+-----------------------------------------------------------------------------+
|i8 : g = randomComplexMap(D, C, Cycle => true, InternalDegree => 3)          |
|                                                                             |
|          1                                                                  |
|o8 = 0 : R  <----------------------------------------------------------------|
|               | -17a3-11a2b+36ab2+35b3+48a2c+2abc+11b2c-38ac2+33bc2+40c3 |  |
|                                                                             |
|          3                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {2} | -17a2-11ab-11b2+48ac+2bc-46c2 -17ab-12b2+48bc-22c2      |
|               {2} | 47a2+35ab+11ac+28c2           a2+36ab+35b2+2ac+11bc+23c2|
|               {2} | 8a2+33ab-28b2+40ac            22a2-38ab+10b2+40bc       |
|                                                                             |
|          3                                              3                   |
|     2 : R  <------------------------------------------ R  : 2               |
|               {4} | a-11b+2c -3a-11c     -3b-c     |                        |
|               {4} | 22a-46b  -47a+2b-46c -47b-22c  |                        |
|               {4} | -23a+28b -7a+28c     2a-7b+23c |                        |
|                                                                             |
|          1                 1                                                |
|     3 : R  <------------- R  : 3                                            |
|               {6} | 2 |                                                     |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|  1                                                                          |
| R  : 0                                                                      |
|                                                                             |
|                                                                             |
|                                   3                                         |
|--------------------------------- R  : 1                                     |
| 3b2-17ac-11bc-6c2            |                                              |
| -3a2+36ac+35bc+18c2          |                                              |
| -47a2+2ab-7b2-38ac+33bc+40c2 |                                              |
+-----------------------------------------------------------------------------+
|i9 : isWellDefined g                                                         |
|                                                                             |
|o9 = true                                                                    |
+-----------------------------------------------------------------------------+
|i10 : f = homomorphism' g                                                    |
|                                                                             |
|           20                                                                |
|o10 = 0 : R   <--------------------------------------------------------------|
|                 {0} | -17a3-11a2b+36ab2+35b3+48a2c+2abc+11b2c-38ac2+33bc2+40|
|                 {1} | -17a2-11ab-11b2+48ac+2bc-46c2                         |
|                 {1} | 47a2+35ab+11ac+28c2                                   |
|                 {1} | 8a2+33ab-28b2+40ac                                    |
|                 {1} | -17ab-12b2+48bc-22c2                                  |
|                 {1} | a2+36ab+35b2+2ac+11bc+23c2                            |
|                 {1} | 22a2-38ab+10b2+40bc                                   |
|                 {1} | 3b2-17ac-11bc-6c2                                     |
|                 {1} | -3a2+36ac+35bc+18c2                                   |
|                 {1} | -47a2+2ab-7b2-38ac+33bc+40c2                          |
|                 {2} | a-11b+2c                                              |
|                 {2} | 22a-46b                                               |
|                 {2} | -23a+28b                                              |
|                 {2} | -3a-11c                                               |
|                 {2} | -47a+2b-46c                                           |
|                 {2} | -7a+28c                                               |
|                 {2} | -3b-c                                                 |
|                 {2} | -47b-22c                                              |
|                 {2} | 2a-7b+23c                                             |
|                 {3} | 2                                                     |
|                                                                             |
|o10 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|        1                                                                    |
|------ R  : 0                                                                |
|c3 |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
+-----------------------------------------------------------------------------+
|i11 : isWellDefined f                                                        |
|                                                                             |
|o11 = true                                                                   |
+-----------------------------------------------------------------------------+
|i12 : assert isCommutative g                                                 |
+-----------------------------------------------------------------------------+
|i13 : assert(degree f === 0)                                                 |
+-----------------------------------------------------------------------------+
|i14 : assert(source f == complex(R^{-3}))                                    |
+-----------------------------------------------------------------------------+
|i15 : assert(target g === D)                                                 |
+-----------------------------------------------------------------------------+
|i16 : assert(homomorphism f == g)                                            |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Ext -- information about functorial
    properties
  * homomorphism'(Matrix) (Macaulay2Doc) -- get the
    element of Hom from a homomorphism
  * homomorphism(ComplexMap) -- get the
    homomorphism from an element of Hom
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes

Ways to use this method:
========================

  * homomorphism'(ComplexMap) -- get the
    element of Hom from a map of complexes

homomorphism(ComplexMap) -- get the homomorphism from an element of Hom
***********************************************************************

Synopsis
========

  * Function: homomorphism (Macaulay2Doc),
  * Usage:
        g = homomorphism f
  * Inputs:
      * f, a map of complexes, a map of the form $f : R^1
        \to Hom(C, D)$, where $C$ and $D$ are complexes, $Hom(C,D)$ has been
        previously computed, and $R$ is the underlying ring of these complexes
  * Outputs:
      * g, a map of complexes, the corresponding map of
        chain complexes from $C$ to $D$

Description
===========

As a first example, consider two Koszul complexes $C$ and $D$. From a random
map $f : R^1 \to Hom(C, D)$, we construct the corresponding map of chain
complexes $g : C \to D$.

+----------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c]                                                |
|                                                                      |
|o1 = R                                                                |
|                                                                      |
|o1 : PolynomialRing                                                   |
+----------------------------------------------------------------------+
|i2 : C = freeResolution ideal"a,b,c"                                  |
|                                                                      |
|      1      3      3      1                                          |
|o2 = R  <-- R  <-- R  <-- R                                           |
|                                                                      |
|     0      1      2      3                                           |
|                                                                      |
|o2 : Complex                                                          |
+----------------------------------------------------------------------+
|i3 : D = freeResolution ideal"a2,b2,c2"                               |
|                                                                      |
|      1      3      3      1                                          |
|o3 = R  <-- R  <-- R  <-- R                                           |
|                                                                      |
|     0      1      2      3                                           |
|                                                                      |
|o3 : Complex                                                          |
+----------------------------------------------------------------------+
|i4 : H = Hom(C,D)                                                     |
|                                                                      |
|      1      6      15      20      15      6      1                  |
|o4 = R  <-- R  <-- R   <-- R   <-- R   <-- R  <-- R                   |
|                                                                      |
|     -3     -2     -1      0       1       2      3                   |
|                                                                      |
|o4 : Complex                                                          |
+----------------------------------------------------------------------+
|i5 : f = randomComplexMap(H, complex R^{-2})                          |
|                                                                      |
|          20                                             1            |
|o5 = 0 : R   <----------------------------------------- R  : 0        |
|                {0} | 24a2-36ab-29b2-30ac+19bc+19c2 |                 |
|                {1} | -10a-29b-8c                   |                 |
|                {1} | -22a-29b-24c                  |                 |
|                {1} | -38a-16b+39c                  |                 |
|                {1} | 21a+34b+19c                   |                 |
|                {1} | -47a-39b-18c                  |                 |
|                {1} | -13a-43b-15c                  |                 |
|                {1} | -28a-47b+38c                  |                 |
|                {1} | 2a+16b+22c                    |                 |
|                {1} | 45a-34b-48c                   |                 |
|                {2} | -47                           |                 |
|                {2} | 47                            |                 |
|                {2} | 19                            |                 |
|                {2} | -16                           |                 |
|                {2} | 7                             |                 |
|                {2} | 15                            |                 |
|                {2} | -23                           |                 |
|                {2} | 39                            |                 |
|                {2} | 43                            |                 |
|                {3} | 0                             |                 |
|                                                                      |
|o5 : ComplexMap                                                       |
+----------------------------------------------------------------------+
|i6 : isWellDefined f                                                  |
|                                                                      |
|o6 = true                                                             |
+----------------------------------------------------------------------+
|i7 : g = homomorphism f                                               |
|                                                                      |
|          1                                         1                 |
|o7 = 0 : R  <------------------------------------- R  : 0             |
|               | 24a2-36ab-29b2-30ac+19bc+19c2 |                      |
|                                                                      |
|          3                                                      3    |
|     1 : R  <-------------------------------------------------- R  : 1|
|               {2} | -10a-29b-8c  21a+34b+19c  -28a-47b+38c |         |
|               {2} | -22a-29b-24c -47a-39b-18c 2a+16b+22c   |         |
|               {2} | -38a-16b+39c -13a-43b-15c 45a-34b-48c  |         |
|                                                                      |
|          3                           3                               |
|     2 : R  <----------------------- R  : 2                           |
|               {4} | -47 -16 -23 |                                    |
|               {4} | 47  7   39  |                                    |
|               {4} | 19  15  43  |                                    |
|                                                                      |
|          1         1                                                 |
|     3 : R  <----- R  : 3                                             |
|               0                                                      |
|                                                                      |
|o7 : ComplexMap                                                       |
+----------------------------------------------------------------------+
|i8 : isWellDefined g                                                  |
|                                                                      |
|o8 = true                                                             |
+----------------------------------------------------------------------+
|i9 : assert not isCommutative g                                       |
+----------------------------------------------------------------------+

The map $g : C \to D$ corresponding to a random map into $Hom(C,D)$ does not
generally commute with the differentials.  However, if the element of
$Hom(C,D)$ is a cycle, then the corresponding map does commute.

+------------------------------------------------------------+
|i10 : f = randomComplexMap(H, complex R^{-2}, Cycle => true)|
|                                                            |
|           20                               1               |
|o10 = 0 : R   <--------------------------- R  : 0           |
|                 {0} | -17a2-11b2+48c2 |                    |
|                 {1} | -17a            |                    |
|                 {1} | -11a            |                    |
|                 {1} | 48a             |                    |
|                 {1} | -17b            |                    |
|                 {1} | -11b            |                    |
|                 {1} | 48b             |                    |
|                 {1} | -17c            |                    |
|                 {1} | -11c            |                    |
|                 {1} | 48c             |                    |
|                 {2} | 0               |                    |
|                 {2} | 0               |                    |
|                 {2} | 0               |                    |
|                 {2} | 0               |                    |
|                 {2} | 0               |                    |
|                 {2} | 0               |                    |
|                 {2} | 0               |                    |
|                 {2} | 0               |                    |
|                 {2} | 0               |                    |
|                 {3} | 0               |                    |
|                                                            |
|o10 : ComplexMap                                            |
+------------------------------------------------------------+
|i11 : isWellDefined f                                       |
|                                                            |
|o11 = true                                                  |
+------------------------------------------------------------+
|i12 : g = homomorphism f                                    |
|                                                            |
|           1                           1                    |
|o12 = 0 : R  <----------------------- R  : 0                |
|                | -17a2-11b2+48c2 |                         |
|                                                            |
|           3                              3                 |
|      1 : R  <-------------------------- R  : 1             |
|                {2} | -17a -17b -17c |                      |
|                {2} | -11a -11b -11c |                      |
|                {2} | 48a  48b  48c  |                      |
|                                                            |
|           3         3                                      |
|      2 : R  <----- R  : 2                                  |
|                0                                           |
|                                                            |
|           1         1                                      |
|      3 : R  <----- R  : 3                                  |
|                0                                           |
|                                                            |
|o12 : ComplexMap                                            |
+------------------------------------------------------------+
|i13 : isWellDefined g                                       |
|                                                            |
|o13 = true                                                  |
+------------------------------------------------------------+
|i14 : assert isCommutative g                                |
+------------------------------------------------------------+
|i15 : assert(degree g === 0)                                |
+------------------------------------------------------------+
|i16 : assert(source g === C)                                |
+------------------------------------------------------------+
|i17 : assert(target g === D)                                |
+------------------------------------------------------------+
|i18 : assert(homomorphism' g == f)                          |
+------------------------------------------------------------+

A homomorphism of non-zero degree can be encoded in (at least) two ways.

+-----------------------------------------------------------------------------+
|i19 : f1 = randomComplexMap(H, complex R^1, Degree => -2)                    |
|                                                                             |
|            6                                              1                 |
|o19 = -2 : R  <------------------------------------------ R  : 0             |
|                 {-2} | 36a2+35ab-38b2+11ac+33bc+40c2 |                      |
|                 {-2} | 11a2+46ab+b2-28ac-3bc+22c2    |                      |
|                 {-2} | -47a2-23ab+2b2-7ac+29bc-47c2  |                      |
|                 {-1} | 15a-37b-13c                   |                      |
|                 {-1} | -10a+30b-18c                  |                      |
|                 {-1} | 39a+27b-22c                   |                      |
|                                                                             |
|o19 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i20 : f2 = map(target f1, (source f1)[2], i -> f1_(i+2))                     |
|                                                                             |
|            6                                              1                 |
|o20 = -2 : R  <------------------------------------------ R  : -2            |
|                 {-2} | 36a2+35ab-38b2+11ac+33bc+40c2 |                      |
|                 {-2} | 11a2+46ab+b2-28ac-3bc+22c2    |                      |
|                 {-2} | -47a2-23ab+2b2-7ac+29bc-47c2  |                      |
|                 {-1} | 15a-37b-13c                   |                      |
|                 {-1} | -10a+30b-18c                  |                      |
|                 {-1} | 39a+27b-22c                   |                      |
|                                                                             |
|o20 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i21 : assert isWellDefined f2                                                |
+-----------------------------------------------------------------------------+
|i22 : g1 = homomorphism f1                                                   |
|                                                                             |
|                     1                                                       |
|o22 = -2 : 0 <----- R  : 0                                                   |
|                0                                                            |
|                                                                             |
|                     3                                                       |
|      -1 : 0 <----- R  : 1                                                   |
|                0                                                            |
|                                                                             |
|           1                                                                 |
|      0 : R  <---------------------------------------------------------------|
|                | 36a2+35ab-38b2+11ac+33bc+40c2 11a2+46ab+b2-28ac-3bc+22c2 -4|
|                                                                             |
|           3                            1                                    |
|      1 : R  <------------------------ R  : 3                                |
|                {2} | 15a-37b-13c  |                                         |
|                {2} | -10a+30b-18c |                                         |
|                {2} | 39a+27b-22c  |                                         |
|                                                                             |
|o22 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                3                                            |
|------------------------------ R  : 2                                        |
|7a2-23ab+2b2-7ac+29bc-47c2 |                                                 |
+-----------------------------------------------------------------------------+
|i23 : g2 = homomorphism f2                                                   |
|                                                                             |
|                     1                                                       |
|o23 = -2 : 0 <----- R  : 0                                                   |
|                0                                                            |
|                                                                             |
|                     3                                                       |
|      -1 : 0 <----- R  : 1                                                   |
|                0                                                            |
|                                                                             |
|           1                                                                 |
|      0 : R  <---------------------------------------------------------------|
|                | 36a2+35ab-38b2+11ac+33bc+40c2 11a2+46ab+b2-28ac-3bc+22c2 -4|
|                                                                             |
|           3                            1                                    |
|      1 : R  <------------------------ R  : 3                                |
|                {2} | 15a-37b-13c  |                                         |
|                {2} | -10a+30b-18c |                                         |
|                {2} | 39a+27b-22c  |                                         |
|                                                                             |
|o23 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                3                                            |
|------------------------------ R  : 2                                        |
|7a2-23ab+2b2-7ac+29bc-47c2 |                                                 |
+-----------------------------------------------------------------------------+
|i24 : assert(g1 == g2)                                                       |
+-----------------------------------------------------------------------------+
|i25 : assert isWellDefined g1                                                |
+-----------------------------------------------------------------------------+
|i26 : assert isWellDefined g2                                                |
+-----------------------------------------------------------------------------+
|i27 : homomorphism' g1 == f1                                                 |
|                                                                             |
|o27 = true                                                                   |
+-----------------------------------------------------------------------------+
|i28 : homomorphism' g2 == f1                                                 |
|                                                                             |
|o28 = true                                                                   |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Ext -- information about functorial
    properties
  * homomorphism(Matrix) (Macaulay2Doc) -- get the
    homomorphism from element of Hom
  * homomorphism(ZZ,Matrix,Complex)
    -- get the homomorphism from an
    element of Hom
  * homomorphism'(ComplexMap) -- get the
    element of Hom from a map of complexes
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes

Ways to use this method:
========================

  * homomorphism(ComplexMap) -- get the
    homomorphism from an element of Hom

homomorphism(ZZ,Matrix,Complex) -- get the homomorphism from an element of Hom
******************************************************************************

Synopsis
========

  * Function: homomorphism (Macaulay2Doc),
  * Usage:
        g = homomorphism(i, f, E)
  * Inputs:
      * i, an integer (Macaulay2Doc),
      * f, a matrix (Macaulay2Doc), a map of the form $f \colon
        R^1 \to E_i$
      * E, a complex, having the form $E =
        \operatorname{Hom}(C, D)$ for some complexes $C$ and $D$
  * Outputs:
      * g, a map of complexes, the corresponding map of
        chain complexes from $C$ to $D$ of degree $i$

Description
===========

An element of the complex $\operatorname{Hom}(C, D)$ corresponds to a map of
complexes from $C$ to $D$.  Given an element in the $i$-th term, this method
returns the corresponding map of complexes of degree $i$.

As a first example, consider two Koszul complexes $C$ and $D$. From a random
map $f \colon R^1 \to Hom(C, D)$, we construct the corresponding map of chain
complexes $g \colon C \to D$.

+----------------------------------------------------+
|i1 : R = ZZ/101[a,b,c];                             |
+----------------------------------------------------+
|i2 : C = freeResolution ideal"a,b,c"                |
|                                                    |
|      1      3      3      1                        |
|o2 = R  <-- R  <-- R  <-- R                         |
|                                                    |
|     0      1      2      3                         |
|                                                    |
|o2 : Complex                                        |
+----------------------------------------------------+
|i3 : D = freeResolution ideal"a2,b2,c2"             |
|                                                    |
|      1      3      3      1                        |
|o3 = R  <-- R  <-- R  <-- R                         |
|                                                    |
|     0      1      2      3                         |
|                                                    |
|o3 : Complex                                        |
+----------------------------------------------------+
|i4 : E = Hom(C,D)                                   |
|                                                    |
|      1      6      15      20      15      6      1|
|o4 = R  <-- R  <-- R   <-- R   <-- R   <-- R  <-- R |
|                                                    |
|     -3     -2     -1      0       1       2      3 |
|                                                    |
|o4 : Complex                                        |
+----------------------------------------------------+
|i5 : f = random(E_2, R^{-5})                        |
|                                                    |
|o5 = {4} | 24a-29b-10c  |                           |
|     {4} | -36a+19b-29c |                           |
|     {4} | -30a+19b-8c  |                           |
|     {5} | -22          |                           |
|     {5} | -29          |                           |
|     {5} | -24          |                           |
|                                                    |
|             6       1                              |
|o5 : Matrix R  <--- R                               |
+----------------------------------------------------+
|i6 : g = homomorphism(2, f, E)                      |
|                                                    |
|          3                            1            |
|o6 = 2 : R  <------------------------ R  : 0        |
|               {4} | 24a-29b-10c  |                 |
|               {4} | -36a+19b-29c |                 |
|               {4} | -30a+19b-8c  |                 |
|                                                    |
|          1                           3             |
|     3 : R  <----------------------- R  : 1         |
|               {6} | -22 -29 -24 |                  |
|                                                    |
|                   3                                |
|     4 : 0 <----- R  : 2                            |
|              0                                     |
|                                                    |
|                   1                                |
|     5 : 0 <----- R  : 3                            |
|              0                                     |
|                                                    |
|o6 : ComplexMap                                     |
+----------------------------------------------------+
|i7 : assert isWellDefined g                         |
+----------------------------------------------------+
|i8 : assert not isCommutative g                     |
+----------------------------------------------------+

The map $g \colon C \to D$ corresponding to a random map into $Hom(C,D)$ does
not generally commute with the differentials.  However, if the element of
$Hom(C,D)$ is a cycle, then the corresponding map does commute.

+-----------------------------------------------------------------------------+
|i9 : h = randomComplexMap(E, complex R^{-2}, Cycle => true, Degree => -1)    |
|                                                                             |
|           15                                                                |
|o9 = -1 : R   <--------------------------------------------------------------|
|                 {-1} | -38a3-16a2b-47ab2-39b3+39a2c-17abc+15b2c-13ac2-3bc2-1|
|                 {-1} | -28a3+16a2b-38ab2-34b3-27a2c-8abc-27b2c-5ac2+7bc2+15c|
|                 {-1} | 2a3-a2b+43ab2+47b3-16a2c-35abc+19b2c+35ac2-41bc2+43c3|
|                 {0}  | 28a2+47ab-34b2+27ac+47bc-11c2                        |
|                 {0}  | -45a2-13ab-39b2+10ac+15bc+40c2                       |
|                 {0}  | 16a2-20ab-43b2-15ac-15bc                             |
|                 {0}  | -2a2+ab+11b2-22ac+19bc-19c2                          |
|                 {0}  | 47a2-47ab+35ac-39bc-18c2                             |
|                 {0}  | 23a2+24ab+33b2+45ac-3bc-15c2                         |
|                 {0}  | -2ab-16b2-28ac+32bc+38c2                             |
|                 {0}  | 17a2-43ab-47b2-3ac+48bc-48c2                         |
|                 {0}  | 36a2-43ab-39b2-5ac-36bc+15c2                         |
|                 {1}  | -17a-11b+48c                                         |
|                 {1}  | -36a-35b-11c                                         |
|                 {1}  | -38a+33b+40c                                         |
|                                                                             |
|o9 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|         1                                                                   |
|------- R  : 0                                                               |
|5c3 |                                                                        |
|3   |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
+-----------------------------------------------------------------------------+
|i10 : f = h_0                                                                |
|                                                                             |
|o10 = {-1} | -38a3-16a2b-47ab2-39b3+39a2c-17abc+15b2c-13ac2-3bc2-15c3 |      |
|      {-1} | -28a3+16a2b-38ab2-34b3-27a2c-8abc-27b2c-5ac2+7bc2+15c3   |      |
|      {-1} | 2a3-a2b+43ab2+47b3-16a2c-35abc+19b2c+35ac2-41bc2+43c3    |      |
|      {0}  | 28a2+47ab-34b2+27ac+47bc-11c2                            |      |
|      {0}  | -45a2-13ab-39b2+10ac+15bc+40c2                           |      |
|      {0}  | 16a2-20ab-43b2-15ac-15bc                                 |      |
|      {0}  | -2a2+ab+11b2-22ac+19bc-19c2                              |      |
|      {0}  | 47a2-47ab+35ac-39bc-18c2                                 |      |
|      {0}  | 23a2+24ab+33b2+45ac-3bc-15c2                             |      |
|      {0}  | -2ab-16b2-28ac+32bc+38c2                                 |      |
|      {0}  | 17a2-43ab-47b2-3ac+48bc-48c2                             |      |
|      {0}  | 36a2-43ab-39b2-5ac-36bc+15c2                             |      |
|      {1}  | -17a-11b+48c                                             |      |
|      {1}  | -36a-35b-11c                                             |      |
|      {1}  | -38a+33b+40c                                             |      |
|                                                                             |
|              15       1                                                     |
|o10 : Matrix R   <--- R                                                      |
+-----------------------------------------------------------------------------+
|i11 : g = homomorphism(-1, f, E)                                             |
|                                                                             |
|                     1                                                       |
|o11 = -1 : 0 <----- R  : 0                                                   |
|                0                                                            |
|                                                                             |
|           1                                                                 |
|      0 : R  <---------------------------------------------------------------|
|                | -38a3-16a2b-47ab2-39b3+39a2c-17abc+15b2c-13ac2-3bc2-15c3 -2|
|                                                                             |
|           3                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {2} | 28a2+47ab-34b2+27ac+47bc-11c2  -2a2+ab+11b2-22ac+19bc-1|
|                {2} | -45a2-13ab-39b2+10ac+15bc+40c2 47a2-47ab+35ac-39bc-18c2|
|                {2} | 16a2-20ab-43b2-15ac-15bc       23a2+24ab+33b2+45ac-3bc-|
|                                                                             |
|           3                            1                                    |
|      2 : R  <------------------------ R  : 3                                |
|                {4} | -17a-11b+48c |                                         |
|                {4} | -36a-35b-11c |                                         |
|                {4} | -38a+33b+40c |                                         |
|                                                                             |
|o11 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|8a3+16a2b-38ab2-34b3-27a2c-8abc-27b2c-5ac2+7bc2+15c3 2a3-a2b+43ab2+47b3-16a2c|
|                                                                             |
|                                       3                                     |
|------------------------------------- R  : 2                                 |
|9c2  -2ab-16b2-28ac+32bc+38c2     |                                          |
|     17a2-43ab-47b2-3ac+48bc-48c2 |                                          |
|15c2 36a2-43ab-39b2-5ac-36bc+15c2 |                                          |
|-----------------------------------------------------------------------------|
|                                   3                                         |
|--------------------------------- R  : 1                                     |
|-35abc+19b2c+35ac2-41bc2+43c3 |                                              |
+-----------------------------------------------------------------------------+
|i12 : assert isWellDefined g                                                 |
+-----------------------------------------------------------------------------+
|i13 : assert isCommutative g                                                 |
+-----------------------------------------------------------------------------+
|i14 : assert(degree g === -1)                                                |
+-----------------------------------------------------------------------------+
|i15 : assert(source g === C)                                                 |
+-----------------------------------------------------------------------------+
|i16 : assert(target g === D)                                                 |
+-----------------------------------------------------------------------------+
|i17 : assert(homomorphism' g == h)                                           |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Ext -- information about functorial
    properties
  * homomorphism(Matrix) (Macaulay2Doc) -- get the
    homomorphism from element of Hom
  * homomorphism'(ComplexMap) -- get the
    element of Hom from a map of complexes
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes

Ways to use this method:
========================

  * homomorphism(ZZ,Matrix,Complex)
    -- get the homomorphism from an
    element of Hom

horseshoeResolution(Complex) -- make the horseshoe resolution
*************************************************************

Synopsis
========

  * Function: horseshoeResolution,
  * Usage:
        (beta, alpha) = horseshoeResolution C
        (beta, alpha) = horseshoeResolution(g, f)
  * Inputs:
      * C, a complex, (or a pair of maps) that is a short exact
        sequence of modules
  * Optional inputs (Macaulay2Doc),:
      * LengthLimit => an integer (Macaulay2Doc), default value
        infinity, limit the lengths of the constructed free resolutions
  * Outputs:
      * a sequence (Macaulay2Doc), consisting of a pair of
        chain complex maps $\beta$ and $\alpha$

Description
===========

Given a short exact sequence of modules

$\phantom{WWWW} 0 \leftarrow N \xleftarrow{g} M \xleftarrow{f} L \leftarrow 0,
$

the horsehoe lemma produces simultaneous free resolutions of $N$, $M$ and $L$,
which form a short exact sequence of complexes. This method returns these two
chain complex maps.

We illustrate this method by constructing simultaneous free resolutions of
three monomial ideals.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c];                                                      |
+-----------------------------------------------------------------------------+
|i2 : I = ideal(a^3, b^3, c^3)                                                |
|                                                                             |
|             3   3   3                                                       |
|o2 = ideal (a , b , c )                                                      |
|                                                                             |
|o2 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i3 : J = I + ideal(a*b*c)                                                    |
|                                                                             |
|             3   3   3                                                       |
|o3 = ideal (a , b , c , a*b*c)                                               |
|                                                                             |
|o3 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i4 : K = I : ideal(a*b*c)                                                    |
|                                                                             |
|             2   2   2                                                       |
|o4 = ideal (c , b , a )                                                      |
|                                                                             |
|o4 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i5 : C = complex{                                                            |
|         map(comodule J, comodule I, 1),                                     |
|         map(comodule I, (comodule K) ** S^{-3}, {{a*b*c}})                  |
|         }                                                                   |
|                                                                             |
|o5 = cokernel | a3 b3 c3 abc | <-- cokernel | a3 b3 c3 | <-- cokernel {3} |  |
|                                                                             |
|     0                             1                         2               |
|                                                                             |
|o5 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|c2 b2 a2 |                                                                   |
+-----------------------------------------------------------------------------+
|i6 : assert isShortExactSequence C                                           |
+-----------------------------------------------------------------------------+
|i7 : (beta, alpha) = horseshoeResolution C                                   |
|                                                                             |
|           1               2                             2                   |
|o7 = (0 : S  <----------- S  : 0                  , 0 : S                    |
|                | 0 1 |                                                      |
|                                                                             |
|           4                             7                                   |
|      1 : S  <------------------------- S  : 1           7                   |
|                {3} | 0 0 0 1 0 0 0 |               1 : S                    |
|                {3} | 0 0 0 0 1 0 0 |                                        |
|                {3} | 0 0 0 0 0 1 0 |                                        |
|                {3} | 0 0 0 0 0 0 1 |                                        |
|                                                                             |
|           6                                 9                               |
|      2 : S  <----------------------------- S  : 2                           |
|                {5} | 0 0 0 1 0 0 0 0 0 |                                    |
|                {5} | 0 0 0 0 1 0 0 0 0 |                                    |
|                {5} | 0 0 0 0 0 1 0 0 0 |                9                   |
|                {6} | 0 0 0 0 0 0 1 0 0 |           2 : S                    |
|                {6} | 0 0 0 0 0 0 0 1 0 |                                    |
|                {6} | 0 0 0 0 0 0 0 0 1 |                                    |
|                                                                             |
|           3                       4                                         |
|      3 : S  <------------------- S  : 3                                     |
|                {7} | 0 1 0 0 |                                              |
|                {7} | 0 0 1 0 |                                              |
|                {7} | 0 0 0 1 |                                              |
|                                                                             |
|                                                                             |
|                                                         4                   |
|                                                    3 : S                    |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|     ------------------------------------------------------------------------|
|                     1                                                       |
|     <------------- S  : 0    )                                              |
|        {3} | 1 |                                                            |
|        {0} | 0 |                                                            |
|                                                                             |
|                         3                                                   |
|     <----------------- S  : 1                                               |
|        {5} | 1 0 0 |                                                        |
|        {5} | 0 1 0 |                                                        |
|        {5} | 0 0 1 |                                                        |
|        {3} | 0 0 0 |                                                        |
|        {3} | 0 0 0 |                                                        |
|        {3} | 0 0 0 |                                                        |
|        {3} | 0 0 0 |                                                        |
|                                                                             |
|                         3                                                   |
|     <----------------- S  : 2                                               |
|        {7} | 1 0 0 |                                                        |
|        {7} | 0 1 0 |                                                        |
|        {7} | 0 0 1 |                                                        |
|        {5} | 0 0 0 |                                                        |
|        {5} | 0 0 0 |                                                        |
|        {5} | 0 0 0 |                                                        |
|        {6} | 0 0 0 |                                                        |
|        {6} | 0 0 0 |                                                        |
|        {6} | 0 0 0 |                                                        |
|                                                                             |
|                     1                                                       |
|     <------------- S  : 3                                                   |
|        {9} | 1 |                                                            |
|        {7} | 0 |                                                            |
|        {7} | 0 |                                                            |
|        {7} | 0 |                                                            |
|                                                                             |
|o7 : Sequence                                                                |
+-----------------------------------------------------------------------------+
|i8 : assert isShortExactSequence(beta, alpha)                                |
+-----------------------------------------------------------------------------+
|i9 : assert(prune HH source alpha == complex C_2)                            |
+-----------------------------------------------------------------------------+
|i10 : assert(prune HH target alpha == complex C_1)                           |
+-----------------------------------------------------------------------------+
|i11 : assert(prune HH target beta == complex C_0)                            |
+-----------------------------------------------------------------------------+
|i12 : assert isFree target alpha                                             |
+-----------------------------------------------------------------------------+

The constructed resolution of the middle term $C_1$ is almost never minimal.

+-----------------------------+
|i13 : target alpha           |
|                             |
|       2      7      9      4|
|o13 = S  <-- S  <-- S  <-- S |
|                             |
|      0      1      2      3 |
|                             |
|o13 : Complex                |
+-----------------------------+
|i14 : freeResolution C_1     |
|                             |
|       1      3      3      1|
|o14 = S  <-- S  <-- S  <-- S |
|                             |
|      0      1      2      3 |
|                             |
|o14 : Complex                |
+-----------------------------+
|i15 : minimize target alpha  |
|                             |
|       1      3      3      1|
|o15 = S  <-- S  <-- S  <-- S |
|                             |
|      0      1      2      3 |
|                             |
|o15 : Complex                |
+-----------------------------+

The optional argument LengthLimit allows one to truncate the constructed free
resolutions.

+-----------------------------------------------------------------------------+
|i16 : (beta, alpha) = horseshoeResolution(C, LengthLimit => 2)               |
|                                                                             |
|            1               2                             2                  |
|o16 = (0 : S  <----------- S  : 0                  , 0 : S                   |
|                 | 0 1 |                                                     |
|                                                                             |
|            4                             7                                  |
|       1 : S  <------------------------- S  : 1           7                  |
|                 {3} | 0 0 0 1 0 0 0 |               1 : S                   |
|                 {3} | 0 0 0 0 1 0 0 |                                       |
|                 {3} | 0 0 0 0 0 1 0 |                                       |
|                 {3} | 0 0 0 0 0 0 1 |                                       |
|                                                                             |
|            6                                 9                              |
|       2 : S  <----------------------------- S  : 2                          |
|                 {5} | 0 0 0 1 0 0 0 0 0 |                                   |
|                 {5} | 0 0 0 0 1 0 0 0 0 |                                   |
|                 {5} | 0 0 0 0 0 1 0 0 0 |                9                  |
|                 {6} | 0 0 0 0 0 0 1 0 0 |           2 : S                   |
|                 {6} | 0 0 0 0 0 0 0 1 0 |                                   |
|                 {6} | 0 0 0 0 0 0 0 0 1 |                                   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      -----------------------------------------------------------------------|
|                      1                                                      |
|      <------------- S  : 0    )                                             |
|         {3} | 1 |                                                           |
|         {0} | 0 |                                                           |
|                                                                             |
|                          3                                                  |
|      <----------------- S  : 1                                              |
|         {5} | 1 0 0 |                                                       |
|         {5} | 0 1 0 |                                                       |
|         {5} | 0 0 1 |                                                       |
|         {3} | 0 0 0 |                                                       |
|         {3} | 0 0 0 |                                                       |
|         {3} | 0 0 0 |                                                       |
|         {3} | 0 0 0 |                                                       |
|                                                                             |
|                          3                                                  |
|      <----------------- S  : 2                                              |
|         {7} | 1 0 0 |                                                       |
|         {7} | 0 1 0 |                                                       |
|         {7} | 0 0 1 |                                                       |
|         {5} | 0 0 0 |                                                       |
|         {5} | 0 0 0 |                                                       |
|         {5} | 0 0 0 |                                                       |
|         {6} | 0 0 0 |                                                       |
|         {6} | 0 0 0 |                                                       |
|         {6} | 0 0 0 |                                                       |
|                                                                             |
|o16 : Sequence                                                               |
+-----------------------------------------------------------------------------+
|i17 : assert isShortExactSequence(beta, alpha)                               |
+-----------------------------------------------------------------------------+
|i18 : prune HH source alpha                                                  |
|                                                                             |
|                                           1                                 |
|o18 = cokernel {3} | c2 b2 a2 | <-- 0 <-- S                                  |
|                                                                             |
|      0                             1     2                                  |
|                                                                             |
|o18 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i19 : assert isFree target alpha                                             |
+-----------------------------------------------------------------------------+

See also
========

  * Towards computing in the derived category
  * isShortExactSequence(Complex), --
    whether a chain complex is a short exact sequence
  * minimize(Complex) -- a quasi-isomorphic
    complex whose terms have minimal rank
  * connectingMap(ComplexMap,ComplexMap)
    -- construct the connecting
    homomorphism on homology
  * connectingExtMap, --
    makes the connecting maps in Ext

Ways to use this method:
========================

  * horseshoeResolution(Complex), --
    make the horseshoe resolution
  * "horseshoeResolution(Matrix,Matrix)"

id _ Complex -- the identity map of a chain complex
***************************************************

Synopsis
========

  * Scripted functor: id (Macaulay2Doc),
  * Usage:
        f = id_C
  * Inputs:
      * C, a complex,
  * Outputs:
      * f, a map of complexes, the identity map from $C$ to
        itself

Description
===========

The chain complexes together with complex morphisms forms a category.  In
particular, every chain complex has an identity map.

+-----------------------------------------------------+
|i1 : R = ZZ/101[x,y]/(x^3, y^3)                      |
|                                                     |
|o1 = R                                               |
|                                                     |
|o1 : QuotientRing                                    |
+-----------------------------------------------------+
|i2 : C = freeResolution(coker vars R, LengthLimit=>6)|
|                                                     |
|      1      2      3      4      5      6      7    |
|o2 = R  <-- R  <-- R  <-- R  <-- R  <-- R  <-- R     |
|                                                     |
|     0      1      2      3      4      5      6     |
|                                                     |
|o2 : Complex                                         |
+-----------------------------------------------------+
|i3 : f = id_C                                        |
|                                                     |
|          1             1                            |
|o3 = 0 : R  <--------- R  : 0                        |
|               | 1 |                                 |
|                                                     |
|          2                   2                      |
|     1 : R  <--------------- R  : 1                  |
|               {1} | 1 0 |                           |
|               {1} | 0 1 |                           |
|                                                     |
|          3                     3                    |
|     2 : R  <----------------- R  : 2                |
|               {2} | 1 0 0 |                         |
|               {3} | 0 1 0 |                         |
|               {3} | 0 0 1 |                         |
|                                                     |
|          4                       4                  |
|     3 : R  <------------------- R  : 3              |
|               {4} | 1 0 0 0 |                       |
|               {4} | 0 1 0 0 |                       |
|               {4} | 0 0 1 0 |                       |
|               {4} | 0 0 0 1 |                       |
|                                                     |
|          5                         5                |
|     4 : R  <--------------------- R  : 4            |
|               {5} | 1 0 0 0 0 |                     |
|               {5} | 0 1 0 0 0 |                     |
|               {6} | 0 0 1 0 0 |                     |
|               {6} | 0 0 0 1 0 |                     |
|               {6} | 0 0 0 0 1 |                     |
|                                                     |
|          6                           6              |
|     5 : R  <----------------------- R  : 5          |
|               {7} | 1 0 0 0 0 0 |                   |
|               {7} | 0 1 0 0 0 0 |                   |
|               {7} | 0 0 1 0 0 0 |                   |
|               {7} | 0 0 0 1 0 0 |                   |
|               {7} | 0 0 0 0 1 0 |                   |
|               {7} | 0 0 0 0 0 1 |                   |
|                                                     |
|          7                             7            |
|     6 : R  <------------------------- R  : 6        |
|               {8} | 1 0 0 0 0 0 0 |                 |
|               {8} | 0 1 0 0 0 0 0 |                 |
|               {8} | 0 0 1 0 0 0 0 |                 |
|               {9} | 0 0 0 1 0 0 0 |                 |
|               {9} | 0 0 0 0 1 0 0 |                 |
|               {9} | 0 0 0 0 0 1 0 |                 |
|               {9} | 0 0 0 0 0 0 1 |                 |
|                                                     |
|o3 : ComplexMap                                      |
+-----------------------------------------------------+
|i4 : assert isWellDefined f                          |
+-----------------------------------------------------+
|i5 : assert isComplexMorphism f                      |
+-----------------------------------------------------+

The identity map corresponds to an element of the Hom complex.

+------------------------------------------------------+
|i6 : R = ZZ/101[a,b,c]                                |
|                                                      |
|o6 = R                                                |
|                                                      |
|o6 : PolynomialRing                                   |
+------------------------------------------------------+
|i7 : I = ideal(a^2, b^2, b*c, c^3)                    |
|                                                      |
|             2   2        3                           |
|o7 = ideal (a , b , b*c, c )                          |
|                                                      |
|o7 : Ideal of R                                       |
+------------------------------------------------------+
|i8 : C = freeResolution I                             |
|                                                      |
|      1      4      5      2                          |
|o8 = R  <-- R  <-- R  <-- R                           |
|                                                      |
|     0      1      2      3                           |
|                                                      |
|o8 : Complex                                          |
+------------------------------------------------------+
|i9 : D = Hom(C, C)                                    |
|                                                      |
|      2      13      34      46      34      13      2|
|o9 = R  <-- R   <-- R   <-- R   <-- R   <-- R   <-- R |
|                                                      |
|     -3     -2      -1      0       1       2       3 |
|                                                      |
|o9 : Complex                                          |
+------------------------------------------------------+
|i10 : homomorphism' id_C                              |
|                                                      |
|           46                  1                      |
|o10 = 0 : R   <-------------- R  : 0                  |
|                 {0}  | 1 |                           |
|                 {0}  | 1 |                           |
|                 {0}  | 0 |                           |
|                 {0}  | 0 |                           |
|                 {1}  | 0 |                           |
|                 {0}  | 0 |                           |
|                 {0}  | 1 |                           |
|                 {0}  | 0 |                           |
|                 {1}  | 0 |                           |
|                 {0}  | 0 |                           |
|                 {0}  | 0 |                           |
|                 {0}  | 1 |                           |
|                 {1}  | 0 |                           |
|                 {-1} | 0 |                           |
|                 {-1} | 0 |                           |
|                 {-1} | 0 |                           |
|                 {0}  | 1 |                           |
|                 {0}  | 1 |                           |
|                 {1}  | 0 |                           |
|                 {1}  | 0 |                           |
|                 {1}  | 0 |                           |
|                 {2}  | 0 |                           |
|                 {-1} | 0 |                           |
|                 {0}  | 1 |                           |
|                 {0}  | 0 |                           |
|                 {0}  | 0 |                           |
|                 {1}  | 0 |                           |
|                 {-1} | 0 |                           |
|                 {0}  | 0 |                           |
|                 {0}  | 1 |                           |
|                 {0}  | 0 |                           |
|                 {1}  | 0 |                           |
|                 {-1} | 0 |                           |
|                 {0}  | 0 |                           |
|                 {0}  | 0 |                           |
|                 {0}  | 1 |                           |
|                 {1}  | 0 |                           |
|                 {-2} | 0 |                           |
|                 {-1} | 0 |                           |
|                 {-1} | 0 |                           |
|                 {-1} | 0 |                           |
|                 {0}  | 1 |                           |
|                 {0}  | 1 |                           |
|                 {1}  | 0 |                           |
|                 {-1} | 0 |                           |
|                 {0}  | 1 |                           |
|                                                      |
|o10 : ComplexMap                                      |
+------------------------------------------------------+

See also
========

  * map(Complex,Complex,ZZ) -- make the
    zero map or identity between chain complexes
  * isWellDefined(ComplexMap) -- whether
    a map of chain complexes is well-defined
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes
  * homomorphism'(ComplexMap) -- get the
    element of Hom from a map of complexes

Ways to use this method:
========================

  * id _ Complex -- the identity map of a chain complex

image(ComplexMap) -- make the image of a map of complexes
*********************************************************

Synopsis
========

  * Function: image (Macaulay2Doc),
  * Usage:
        E = image f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * E, a complex,

Description
===========

If $f : C \to D$ is a map of chain complexes of degree $d$, then the image is
the complex $E$ whose $i-th$ is $image(f_{i-d})$, and whose differential is
induced from the differential on the target.

In the following example, we first construct a random complex morphism $f : C
\to D$.  We consider the exact sequence $0 \to D \to cone(f) \to C[-1] \to 0$.
For the maps $g : D \to cone(f)$ and $h : cone(f) \to C[-1]$, we compute the
image.

+--------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c,d];                                           |
+--------------------------------------------------------------------+
|i2 : C = freeResolution ideal(b^2-a*c, b*c-a*d, c^2-b*d)            |
|                                                                    |
|      1      3      2                                               |
|o2 = S  <-- S  <-- S                                                |
|                                                                    |
|     0      1      2                                                |
|                                                                    |
|o2 : Complex                                                        |
+--------------------------------------------------------------------+
|i3 : D = freeResolution ideal(a,b,c)                                |
|                                                                    |
|      1      3      3      1                                        |
|o3 = S  <-- S  <-- S  <-- S                                         |
|                                                                    |
|     0      1      2      3                                         |
|                                                                    |
|o3 : Complex                                                        |
+--------------------------------------------------------------------+
|i4 : f = randomComplexMap(D, C, Cycle => true, InternalDegree => 0) |
|                                                                    |
|          1               1                                         |
|o4 = 0 : S  <----------- S  : 0                                     |
|               | -22 |                                              |
|                                                                    |
|          3                                                    3    |
|     1 : S  <------------------------------------------------ S  : 1|
|               {1} | 36b+3c       30b-19c+22d -29b-10c    |         |
|               {1} | -36a-22b+29c -30a-14c    29a+29c+22d |         |
|               {1} | 19a-29b      19a-8b      10a-29b-22c |         |
|                                                                    |
|          3                                                 2       |
|     2 : S  <--------------------------------------------- S  : 2   |
|               {2} | -29a-30b+31c-22d 29b+6c-36d       |            |
|               {2} | -10a+24b+3c      34b-19c+19d      |            |
|               {2} | 24a-8b+29c       -24a-29b-14c-29d |            |
|                                                                    |
|o4 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i5 : Cf = cone f                                                    |
|                                                                    |
|      1      4      6      3                                        |
|o5 = S  <-- S  <-- S  <-- S                                         |
|                                                                    |
|     0      1      2      3                                         |
|                                                                    |
|o5 : Complex                                                        |
+--------------------------------------------------------------------+
|i6 : g = canonicalMap(Cf, D)                                        |
|                                                                    |
|          1             1                                           |
|o6 = 0 : S  <--------- S  : 0                                       |
|               | 1 |                                                |
|                                                                    |
|          4                     3                                   |
|     1 : S  <----------------- S  : 1                               |
|               {0} | 0 0 0 |                                        |
|               {1} | 1 0 0 |                                        |
|               {1} | 0 1 0 |                                        |
|               {1} | 0 0 1 |                                        |
|                                                                    |
|          6                     3                                   |
|     2 : S  <----------------- S  : 2                               |
|               {2} | 0 0 0 |                                        |
|               {2} | 0 0 0 |                                        |
|               {2} | 0 0 0 |                                        |
|               {2} | 1 0 0 |                                        |
|               {2} | 0 1 0 |                                        |
|               {2} | 0 0 1 |                                        |
|                                                                    |
|          3                 1                                       |
|     3 : S  <------------- S  : 3                                   |
|               {3} | 0 |                                            |
|               {3} | 0 |                                            |
|               {3} | 1 |                                            |
|                                                                    |
|o6 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i7 : h = canonicalMap(C[-1], Cf)                                    |
|                                                                    |
|          1                   4                                     |
|o7 = 1 : S  <--------------- S  : 1                                 |
|               | 1 0 0 0 |                                          |
|                                                                    |
|          3                           6                             |
|     2 : S  <----------------------- S  : 2                         |
|               {2} | 1 0 0 0 0 0 |                                  |
|               {2} | 0 1 0 0 0 0 |                                  |
|               {2} | 0 0 1 0 0 0 |                                  |
|                                                                    |
|          2                     3                                   |
|     3 : S  <----------------- S  : 3                               |
|               {3} | 1 0 0 |                                        |
|               {3} | 0 1 0 |                                        |
|                                                                    |
|o7 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i8 : prune image g == D                                             |
|                                                                    |
|o8 = true                                                           |
+--------------------------------------------------------------------+
|i9 : prune image h == C[-1]                                         |
|                                                                    |
|o9 = true                                                           |
+--------------------------------------------------------------------+

There is a canonical map of complexes from the image to the target.

+-------------------------------------------------------------------+
|i10 : g1 = canonicalMap(target g, image g)                         |
|                                                                   |
|           1                                                       |
|o10 = 0 : S  <--------- image | 1 | : 0                            |
|                | 1 |                                              |
|                                                                   |
|           4                                                       |
|      1 : S  <----------------- image {0} | 0 0 0 | : 1            |
|                {0} | 0 0 0 |         {1} | 1 0 0 |                |
|                {1} | 1 0 0 |         {1} | 0 1 0 |                |
|                {1} | 0 1 0 |         {1} | 0 0 1 |                |
|                {1} | 0 0 1 |                                      |
|                                                                   |
|           6                                                       |
|      2 : S  <----------------- image {2} | 0 0 0 | : 2            |
|                {2} | 0 0 0 |         {2} | 0 0 0 |                |
|                {2} | 0 0 0 |         {2} | 0 0 0 |                |
|                {2} | 0 0 0 |         {2} | 1 0 0 |                |
|                {2} | 1 0 0 |         {2} | 0 1 0 |                |
|                {2} | 0 1 0 |         {2} | 0 0 1 |                |
|                {2} | 0 0 1 |                                      |
|                                                                   |
|           3                                                       |
|      3 : S  <------------- image {3} | 0 | : 3                    |
|                {3} | 0 |         {3} | 0 |                        |
|                {3} | 0 |         {3} | 1 |                        |
|                {3} | 1 |                                          |
|                                                                   |
|o10 : ComplexMap                                                   |
+-------------------------------------------------------------------+
|i11 : ker g1 == 0                                                  |
|                                                                   |
|o11 = true                                                         |
+-------------------------------------------------------------------+
|i12 : image g1 == image g                                          |
|                                                                   |
|o12 = true                                                         |
+-------------------------------------------------------------------+
|i13 : h1 = canonicalMap(target h, image h)                         |
|                                                                   |
|           1                                                       |
|o13 = 1 : S  <--------------- image | 1 0 0 0 | : 1                |
|                | 1 0 0 0 |                                        |
|                                                                   |
|           3                                                       |
|      2 : S  <----------------------- image {2} | 1 0 0 0 0 0 | : 2|
|                {2} | 1 0 0 0 0 0 |         {2} | 0 1 0 0 0 0 |    |
|                {2} | 0 1 0 0 0 0 |         {2} | 0 0 1 0 0 0 |    |
|                {2} | 0 0 1 0 0 0 |                                |
|                                                                   |
|           2                                                       |
|      3 : S  <----------------- image {3} | 1 0 0 | : 3            |
|                {3} | 1 0 0 |         {3} | 0 1 0 |                |
|                {3} | 0 1 0 |                                      |
|                                                                   |
|o13 : ComplexMap                                                   |
+-------------------------------------------------------------------+
|i14 : ker h1 == 0                                                  |
|                                                                   |
|o14 = true                                                         |
+-------------------------------------------------------------------+
|i15 : image h1 == image h                                          |
|                                                                   |
|o15 = true                                                         |
+-------------------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * image (Macaulay2Doc) -- image of a map
  * coimage(ComplexMap) -- make the coimage of
    a map of complexes
  * kernel(ComplexMap) -- make the kernel of a
    map of complexes
  * cokernel(ComplexMap) -- make the cokernel
    of a map of complexes
  * canonicalMap -- gets the natural map arising from
    various constructions

Ways to use this method:
========================

  * image(ComplexMap) -- make the image of a map
    of complexes

inducedMap(Complex,Complex) -- make the map of complexes induced at each term by the identity map
*************************************************************************************************

Synopsis
========

  * Function: inducedMap (Macaulay2Doc),
  * Usage:
        f = inducedMap(D, C)
  * Inputs:
      * C, a complex,
      * D, a complex,
  * Optional inputs (Macaulay2Doc),:
      * Degree (Macaulay2Doc),
        => an integer (Macaulay2Doc), default value null, specify
        the degree of the map of complexes, if not 0
      * Verify (Macaulay2Doc),
        => a Boolean value (Macaulay2Doc), default value
        true, if true, check that the resulting maps are well-defined
  * Outputs:
      * f, a map of complexes,

Description
===========

Let $d$ be the value of the optional argument Degree, or zero, if not given.
For each $i$, the terms $D_{i+d}$ and $C_i$ must be subquotients of the same
ambient free module.  This method returns the complex map induced by the
identity on each of these free modules.

If Verify => true is given, then this method also checks that these identity
maps induced well-defined maps.  This can be a relatively expensive
computation.

We illustrate this method by truncating a free resolution at two distinct
internal degrees.  We check that the various induced maps compose to give
another induced map.

+-----------------------------------------------------------------------------+
|i1 : kk = ZZ/32003                                                           |
|                                                                             |
|o1 = kk                                                                      |
|                                                                             |
|o1 : QuotientRing                                                            |
+-----------------------------------------------------------------------------+
|i2 : R = kk[a,b,c]                                                           |
|                                                                             |
|o2 = R                                                                       |
|                                                                             |
|o2 : PolynomialRing                                                          |
+-----------------------------------------------------------------------------+
|i3 : F = freeResolution (ideal gens R)^2                                     |
|                                                                             |
|      1      6      8      3                                                 |
|o3 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : C1 = truncate(3, F)                                                     |
|                                                                             |
|                                                                             |
|o4 = image | c3 bc2 ac2 b2c abc a2c b3 ab2 a2b a3 | <-- image {2} | c b a 0 0|
|                                                              {2} | 0 0 0 c b|
|     0                                                        {2} | 0 0 0 0 0|
|                                                              {2} | 0 0 0 0 0|
|                                                              {2} | 0 0 0 0 0|
|                                                              {2} | 0 0 0 0 0|
|                                                                             |
|                                                        1                    |
|                                                                             |
|o4 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|                                 8      3                                    |
|0 0 0 0 0 0 0 0 0 0 0 0 0 | <-- R  <-- R                                     |
|a 0 0 0 0 0 0 0 0 0 0 0 0 |                                                  |
|0 c b a 0 0 0 0 0 0 0 0 0 |     2      3                                     |
|0 0 0 0 c b a 0 0 0 0 0 0 |                                                  |
|0 0 0 0 0 0 0 c b a 0 0 0 |                                                  |
|0 0 0 0 0 0 0 0 0 0 c b a |                                                  |
+-----------------------------------------------------------------------------+
|i5 : C2 = truncate(4, F)                                                     |
|                                                                             |
|                                                                             |
|o5 = image | c4 bc3 ac3 b2c2 abc2 a2c2 b3c ab2c a2bc a3c b4 ab3 a2b2 a3b a4 ||
|                                                                             |
|     0                                                                       |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o5 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|                                                                             |
|<-- image {2} | c2 bc ac b2 ab a2 0  0  0  0  0  0  0  0  0  0  0  0  0  0   |
|          {2} | 0  0  0  0  0  0  c2 bc ac b2 ab a2 0  0  0  0  0  0  0  0   |
|          {2} | 0  0  0  0  0  0  0  0  0  0  0  0  c2 bc ac b2 ab a2 0  0   |
|          {2} | 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  c2 bc  |
|          {2} | 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   |
|          {2} | 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   |
|                                                                             |
|    1                                                                        |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  | <-- image {3} | c b a 0 0 0|
|0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  |           {3} | 0 0 0 c b a|
|0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  |           {3} | 0 0 0 0 0 0|
|ac b2 ab a2 0  0  0  0  0  0  0  0  0  0  0  0  |           {3} | 0 0 0 0 0 0|
|0  0  0  0  c2 bc ac b2 ab a2 0  0  0  0  0  0  |           {3} | 0 0 0 0 0 0|
|0  0  0  0  0  0  0  0  0  0  c2 bc ac b2 ab a2 |           {3} | 0 0 0 0 0 0|
|                                                            {3} | 0 0 0 0 0 0|
|                                                            {3} | 0 0 0 0 0 0|
|                                                                             |
|                                                      2                      |
|-----------------------------------------------------------------------------|
|                                           3                                 |
|0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | <-- R                                  |
|0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                                        |
|c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |     3                                  |
|0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 |                                        |
|0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 |                                        |
|0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 |                                        |
|0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 |                                        |
|0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a |                                        |
+-----------------------------------------------------------------------------+
|i6 : assert isWellDefined C1                                                 |
+-----------------------------------------------------------------------------+
|i7 : assert isWellDefined C2                                                 |
+-----------------------------------------------------------------------------+
|i8 : f = inducedMap(C1, C2)                                                  |
|                                                                             |
|o8 = 0 : image | c3 bc2 ac2 b2c abc a2c b3 ab2 a2b a3 | <--------------------|
|                                                           {3} | c 0 0 0 0 0 |
|                                                           {3} | 0 c 0 0 0 0 |
|                                                           {3} | 0 0 c 0 0 0 |
|                                                           {3} | 0 0 0 c 0 0 |
|                                                           {3} | 0 0 0 0 c 0 |
|                                                           {3} | 0 0 0 0 0 c |
|                                                           {3} | 0 0 0 0 0 0 |
|                                                           {3} | 0 0 0 0 0 0 |
|                                                           {3} | 0 0 0 0 0 0 |
|                                                           {3} | 0 0 0 0 0 0 |
|                                                                             |
|     1 : image {2} | c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | <-----------------|
|               {2} | 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 |    {3} | c 0 0 0 0|
|               {2} | 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 |    {3} | 0 c 0 b 0|
|               {2} | 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 |    {3} | 0 0 c 0 b|
|               {2} | 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 |    {3} | 0 0 0 0 0|
|               {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a |    {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                              {3} | 0 0 0 0 0|
|                                                                             |
|          8                                                                  |
|     2 : R  <----------------------------------------------------------- imag|
|               {3} | c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |       |
|               {3} | 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |       |
|               {3} | 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |       |
|               {3} | 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 |       |
|               {3} | 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 |       |
|               {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 |       |
|               {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 |       |
|               {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a |       |
|                                                                             |
|          3                     3                                            |
|     3 : R  <----------------- R  : 3                                        |
|               {4} | 1 0 0 |                                                 |
|               {4} | 0 1 0 |                                                 |
|               {4} | 0 0 1 |                                                 |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|--------------------- image | c4 bc3 ac3 b2c2 abc2 a2c2 b3c ab2c a2bc a3c b4 |
|0 0 0 0 0 0 0 0 0 |                                                          |
|0 0 0 0 0 0 0 0 0 |                                                          |
|0 0 0 0 0 0 0 0 0 |                                                          |
|0 0 0 0 0 0 0 0 0 |                                                          |
|0 0 0 0 0 0 0 0 0 |                                                          |
|0 0 0 0 0 0 0 0 0 |                                                          |
|c 0 0 0 b 0 0 0 0 |                                                          |
|0 c 0 0 0 b 0 0 0 |                                                          |
|0 0 c 0 0 0 b 0 0 |                                                          |
|0 0 0 c 0 0 0 b a |                                                          |
|                                                                             |
|------------------------------------------------------------------ image {2} |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         {2} |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         {2} |
| a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         {2} |
| 0 c 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         {2} |
| 0 0 c 0 b 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         {2} |
| 0 0 0 c 0 b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 c 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 0 c 0 b 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 0 0 c 0 b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 c 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c 0 b 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c 0 b a 0 0 0 0 0 0 0 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c 0 0 0 0 0 0 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c 0 b 0 0 0 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c 0 b a 0 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c 0 0 0 0 0 |             |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c 0 b 0 0 |             |
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c 0 b a |             |
|                                                                             |
|                                                                             |
|e {3} | c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | : 2                |
|  {3} | 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                    |
|  {3} | 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                    |
|  {3} | 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 |                    |
|  {3} | 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 |                    |
|  {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 |                    |
|  {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 |                    |
|  {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a |                    |
|-----------------------------------------------------------------------------|
|ab3 a2b2 a3b a4 | : 0                                                        |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|| c2 bc ac b2 ab a2 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  |
|| 0  0  0  0  0  0  c2 bc ac b2 ab a2 0  0  0  0  0  0  0  0  0  0  0  0  0  |
|| 0  0  0  0  0  0  0  0  0  0  0  0  c2 bc ac b2 ab a2 0  0  0  0  0  0  0  |
|| 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  c2 bc ac b2 ab a2 0  |
|| 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  c2 |
|| 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  |
|-----------------------------------------------------------------------------|
|0  0  0  0  0  0  0  0  0  0  0  | : 1                                       |
|0  0  0  0  0  0  0  0  0  0  0  |                                           |
|0  0  0  0  0  0  0  0  0  0  0  |                                           |
|0  0  0  0  0  0  0  0  0  0  0  |                                           |
|bc ac b2 ab a2 0  0  0  0  0  0  |                                           |
|0  0  0  0  0  c2 bc ac b2 ab a2 |                                           |
+-----------------------------------------------------------------------------+
|i9 : assert isWellDefined f                                                  |
+-----------------------------------------------------------------------------+
|i10 : f1 = inducedMap(F, C1)                                                 |
|                                                                             |
|           1                                                                 |
|o10 = 0 : R  <-------------------------------------------- image | c3 bc2 ac2|
|                | c3 bc2 ac2 b2c abc a2c b3 ab2 a2b a3 |                     |
|                                                                             |
|           6                                                                 |
|      1 : R  <----------------------------------------------- image {2} | c b|
|                {2} | c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         {2} | 0 0|
|                {2} | 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 |         {2} | 0 0|
|                {2} | 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 |         {2} | 0 0|
|                {2} | 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 |         {2} | 0 0|
|                {2} | 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 |         {2} | 0 0|
|                {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a |                  |
|                                                                             |
|           8                               8                                 |
|      2 : R  <--------------------------- R  : 2                             |
|                {3} | 1 0 0 0 0 0 0 0 |                                      |
|                {3} | 0 1 0 0 0 0 0 0 |                                      |
|                {3} | 0 0 1 0 0 0 0 0 |                                      |
|                {3} | 0 0 0 1 0 0 0 0 |                                      |
|                {3} | 0 0 0 0 1 0 0 0 |                                      |
|                {3} | 0 0 0 0 0 1 0 0 |                                      |
|                {3} | 0 0 0 0 0 0 1 0 |                                      |
|                {3} | 0 0 0 0 0 0 0 1 |                                      |
|                                                                             |
|           3                     3                                           |
|      3 : R  <----------------- R  : 3                                       |
|                {4} | 1 0 0 |                                                |
|                {4} | 0 1 0 |                                                |
|                {4} | 0 0 1 |                                                |
|                                                                             |
|o10 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|b2c abc a2c b3 ab2 a2b a3 | : 0                                              |
|                                                                             |
|                                                                             |
|                                                                             |
|a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | : 1                                        |
|0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 |                                            |
|0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 |                                            |
|0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 |                                            |
|0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 |                                            |
|0 0 0 0 0 0 0 0 0 0 0 0 0 c b a |                                            |
+-----------------------------------------------------------------------------+
|i11 : f2 = inducedMap(F, C2)                                                 |
|                                                                             |
|           1                                                                 |
|o11 = 0 : R  <---------------------------------------------------------------|
|                | c4 bc3 ac3 b2c2 abc2 a2c2 b3c ab2c a2bc a3c b4 ab3 a2b2 a3b|
|                                                                             |
|           6                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {2} | c2 bc ac b2 ab a2 0  0  0  0  0  0  0  0  0  0  0  0  0|
|                {2} | 0  0  0  0  0  0  c2 bc ac b2 ab a2 0  0  0  0  0  0  0|
|                {2} | 0  0  0  0  0  0  0  0  0  0  0  0  c2 bc ac b2 ab a2 0|
|                {2} | 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  c|
|                {2} | 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0|
|                {2} | 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0|
|                                                                             |
|           8                                                                 |
|      2 : R  <----------------------------------------------------------- ima|
|                {3} | c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |      |
|                {3} | 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |      |
|                {3} | 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |      |
|                {3} | 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 |      |
|                {3} | 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 |      |
|                {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 |      |
|                {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 |      |
|                {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a |      |
|                                                                             |
|           3                     3                                           |
|      3 : R  <----------------- R  : 3                                       |
|                {4} | 1 0 0 |                                                |
|                {4} | 0 1 0 |                                                |
|                {4} | 0 0 1 |                                                |
|                                                                             |
|o11 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|------- image | c4 bc3 ac3 b2c2 abc2 a2c2 b3c ab2c a2bc a3c b4 ab3 a2b2      |
| a4 |                                                                        |
|                                                                             |
|                                                                             |
|-------------------------------------------------------- image {2} | c2      |
|  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  |         {2} | 0       |
|  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  |         {2} | 0       |
|  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  |         {2} | 0       |
|2 bc ac b2 ab a2 0  0  0  0  0  0  0  0  0  0  0  0  |         {2} | 0       |
|  0  0  0  0  0  c2 bc ac b2 ab a2 0  0  0  0  0  0  |         {2} | 0       |
|  0  0  0  0  0  0  0  0  0  0  0  c2 bc ac b2 ab a2 |                       |
|                                                                             |
|                                                                             |
|ge {3} | c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | : 2               |
|   {3} | 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                   |
|   {3} | 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                   |
|   {3} | 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 0 0 0 |                   |
|   {3} | 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 0 0 0 |                   |
|   {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 0 0 0 |                   |
|   {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a 0 0 0 |                   |
|   {3} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c b a |                   |
|-----------------------------------------------------------------------------|
|a3b a4 | : 0                                                                 |
|                                                                             |
|                                                                             |
|                                                                             |
|bc ac b2 ab a2 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 |
|0  0  0  0  0  c2 bc ac b2 ab a2 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 |
|0  0  0  0  0  0  0  0  0  0  0  c2 bc ac b2 ab a2 0  0  0  0  0  0  0  0  0 |
|0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  c2 bc ac b2 ab a2 0  0  0 |
|0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  c2 bc ac|
|0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 |
|-----------------------------------------------------------------------------|
|0  0  0  0  0  0  0  0  0  | : 1                                             |
|0  0  0  0  0  0  0  0  0  |                                                 |
|0  0  0  0  0  0  0  0  0  |                                                 |
|0  0  0  0  0  0  0  0  0  |                                                 |
|b2 ab a2 0  0  0  0  0  0  |                                                 |
|0  0  0  c2 bc ac b2 ab a2 |                                                 |
+-----------------------------------------------------------------------------+
|i12 : assert isWellDefined f1                                                |
+-----------------------------------------------------------------------------+
|i13 : assert isWellDefined f2                                                |
+-----------------------------------------------------------------------------+
|i14 : assert(f2 == f1 * f)                                                   |
+-----------------------------------------------------------------------------+

See also
========

  * inducedMap(Module,Module) (Macaulay2Doc)
    -- compute the map induced
    by the identity

Ways to use this method:
========================

  * inducedMap(Complex,Complex), --
    make the map of complexes induced at each term by the identity map

isCommutative(ComplexMap) -- whether a complex map commutes with the differentials
**********************************************************************************

Synopsis
========

  * Function: isCommutative (Macaulay2Doc),
  * Usage:
        isCommutative f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when $f$
        commutes with the differentials

Description
===========

For a complex map $f : C \to D$ of degree $d$, this method checks whether, for
all $i$, we have $dd^D_{i+d} * f_i = (-1)^d * (f_{i-1} * dd^C_i)$.

We first construct a random complex map which commutes with the differential.

+-----------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c];                                                |
+-----------------------------------------------------------------------+
|i2 : C = freeResolution coker vars S                                   |
|                                                                       |
|      1      3      3      1                                           |
|o2 = S  <-- S  <-- S  <-- S                                            |
|                                                                       |
|     0      1      2      3                                            |
|                                                                       |
|o2 : Complex                                                           |
+-----------------------------------------------------------------------+
|i3 : D = C ** C                                                        |
|                                                                       |
|      1      6      15      20      15      6      1                   |
|o3 = S  <-- S  <-- S   <-- S   <-- S   <-- S  <-- S                    |
|                                                                       |
|     0      1      2       3       4       5      6                    |
|                                                                       |
|o3 : Complex                                                           |
+-----------------------------------------------------------------------+
|i4 : f1 = randomComplexMap(D, C, Boundary => true, InternalDegree => 1)|
|                                                                       |
|          1                       1                                    |
|o4 = 0 : S  <------------------- S  : 0                                |
|               | -5a-17b-11c |                                         |
|                                                                       |
|          6                                                      3     |
|     1 : S  <-------------------------------------------------- S  : 1 |
|               {1} | 2a-28b+50c   -28a+39b-13c -23a-b-48c   |          |
|               {1} | 26a-16b+42c  41a-20b-19c  23a-11b-16c  |          |
|               {1} | 18a+31b+19c  -5a-23b-48c  50a-38b-19c  |          |
|               {1} | -7a-25b-38c  28a-36b+16c  23a-b-4c     |          |
|               {1} | 10a+16b-21c  -49a+3b-41c  -21a+11b+32c |          |
|               {1} | -41a+49b-19c 2a-29b+48c   -3a+5b+8c    |          |
|                                                                       |
|          15                                                      3    |
|     2 : S   <-------------------------------------------------- S  : 2|
|                {2} | 33a+7b-12c   16a-20b+41c  -39a-42b+11c |         |
|                {2} | 30a+40b-7c   -2a+46b+14c  4a+20b+35c   |         |
|                {2} | -3a-39b+2c   -39a-30b+47c 22a-34b-43c  |         |
|                {2} | -28a+39b+9c  -23a+32b+46c 47b-47c      |         |
|                {2} | 8a-25b+14c   7a-33b+16c   39a+3b-11c   |         |
|                {2} | -35a+8b+10c  -49a-20b+7c  -4a+33b+22c  |         |
|                {2} | 31a+35b-8c   -17a-20b-19c -8a-43b+4c   |         |
|                {2} | -28a+16b-29c 42a+43c      -39a-11b-37c |         |
|                {2} | 15a+8b-39c   -25a+30b     -25a-4b-16c  |         |
|                {2} | 8a-14b-7c    3a+33b-36c   -22a+41b+48c |         |
|                {2} | -24a+49b+2c  -37a+44b+5c  -19a+7b-24c  |         |
|                {2} | 50a+18b      43a+23b-19c  49a-38b+48c  |         |
|                {2} | -18a+42c     -38a+33b+34c -8a-2b-22c   |         |
|                {2} | 10a-b-10c    46b-45c      -22a-32b-6c  |         |
|                {2} | -25a+39c     -45a+44b-21c -50a+12b-25c |         |
|                                                                       |
|          20                            1                              |
|     3 : S   <------------------------ S  : 3                          |
|                {3} | 9a+22b+11c   |                                   |
|                {3} | -39a-32b+46c |                                   |
|                {3} | 4a+9b-28c    |                                   |
|                {3} | 13a+32b+c    |                                   |
|                {3} | -26a+20b-3c  |                                   |
|                {3} | 22a-24b+22c  |                                   |
|                {3} | -49a+30b-47c |                                   |
|                {3} | -11a+48b-23c |                                   |
|                {3} | -8a+15b-7c   |                                   |
|                {3} | 43a-39b+2c   |                                   |
|                {3} | -8a+29c      |                                   |
|                {3} | 36a-33b-47c  |                                   |
|                {3} | -3a+49b+15c  |                                   |
|                {3} | -22a+33b-37c |                                   |
|                {3} | -30a+19b-13c |                                   |
|                {3} | 41a-17b-10c  |                                   |
|                {3} | 16a+20b+30c  |                                   |
|                {3} | -28a-44b-18c |                                   |
|                {3} | -6a+39b+39c  |                                   |
|                {3} | 35a-36b+27c  |                                   |
|                                                                       |
|o4 : ComplexMap                                                        |
+-----------------------------------------------------------------------+
|i5 : isCommutative f1                                                  |
|                                                                       |
|o5 = true                                                              |
+-----------------------------------------------------------------------+
|i6 : assert(degree f1 == 0)                                            |
+-----------------------------------------------------------------------+
|i7 : assert isNullHomotopic f1                                         |
+-----------------------------------------------------------------------+
|i8 : assert(source f1 == C and target f1 == D)                         |
+-----------------------------------------------------------------------+

We next generate a complex map that is commutative and (likely) induces a
nontrivial map on homology.

+-----------------------------------------------+
|i9 : f2 = randomComplexMap(D, C, Cycle => true)|
|                                               |
|          1               1                    |
|o9 = 0 : S  <----------- S  : 0                |
|               | -40 |                         |
|                                               |
|          6                           3        |
|     1 : S  <----------------------- S  : 1    |
|               {1} | -44 -48 22  |             |
|               {1} | 41  2   1   |             |
|               {1} | 18  -1  -9  |             |
|               {1} | 4   48  -22 |             |
|               {1} | -41 -42 -1  |             |
|               {1} | -18 1   -31 |             |
|                                               |
|          15                           3       |
|     2 : S   <----------------------- S  : 2   |
|                {2} | -11 -3  -35 |            |
|                {2} | -41 22  6   |            |
|                {2} | -49 -25 31  |            |
|                {2} | -48 22  0   |            |
|                {2} | 13  4   35  |            |
|                {2} | 40  -31 -6  |            |
|                {2} | 33  -3  -13 |            |
|                {2} | -41 0   1   |            |
|                {2} | 31  25  -40 |            |
|                {2} | -41 -35 -47 |            |
|                {2} | -49 35  29  |            |
|                {2} | 0   -18 1   |            |
|                {2} | -9  -4  -13 |            |
|                {2} | -40 35  -47 |            |
|                {2} | -31 35  -2  |            |
|                                               |
|          20                   1               |
|     3 : S   <--------------- S  : 3           |
|                {3} | -9  |                    |
|                {3} | -35 |                    |
|                {3} | 6   |                    |
|                {3} | 40  |                    |
|                {3} | 3   |                    |
|                {3} | -31 |                    |
|                {3} | 25  |                    |
|                {3} | -2  |                    |
|                {3} | -41 |                    |
|                {3} | -49 |                    |
|                {3} | -13 |                    |
|                {3} | 4   |                    |
|                {3} | 30  |                    |
|                {3} | -47 |                    |
|                {3} | 27  |                    |
|                {3} | -40 |                    |
|                {3} | 37  |                    |
|                {3} | -35 |                    |
|                {3} | -31 |                    |
|                {3} | -39 |                    |
|                                               |
|o9 : ComplexMap                                |
+-----------------------------------------------+
|i10 : isCommutative f2                         |
|                                               |
|o10 = true                                     |
+-----------------------------------------------+
|i11 : assert(degree f2 == 0)                   |
+-----------------------------------------------+
|i12 : assert isComplexMorphism f2              |
+-----------------------------------------------+

When the degree of the complex map is odd, isCommutative determines whether the
map is anti-commutative.  We illustrate this for one square.

+-----------------------------------------------------------------------------+
|i13 : f3 = randomComplexMap(D, C, Cycle => true, Degree=>1, InternalDegree =>|
|                                                                             |
|           6                   1                                             |
|o13 = 1 : S  <--------------- S  : 0                                         |
|                {1} | -26 |                                                  |
|                {1} | -50 |                                                  |
|                {1} | 1   |                                                  |
|                {1} | 26  |                                                  |
|                {1} | 50  |                                                  |
|                {1} | -1  |                                                  |
|                                                                             |
|           15                           3                                    |
|      2 : S   <----------------------- S  : 1                                |
|                 {2} | 35  -16 -48 |                                         |
|                 {2} | 17  49  -40 |                                         |
|                 {2} | 1   44  11  |                                         |
|                 {2} | 26  0   0   |                                         |
|                 {2} | 15  16  48  |                                         |
|                 {2} | -18 -49 40  |                                         |
|                 {2} | 35  10  -48 |                                         |
|                 {2} | 0   50  0   |                                         |
|                 {2} | -1  -45 -11 |                                         |
|                 {2} | 17  49  -14 |                                         |
|                 {2} | 1   44  -40 |                                         |
|                 {2} | 0   0   -1  |                                         |
|                 {2} | -15 10  -48 |                                         |
|                 {2} | 18  49  -14 |                                         |
|                 {2} | 1   45  -40 |                                         |
|                                                                             |
|           20                           3                                    |
|      3 : S   <----------------------- S  : 2                                |
|                 {3} | 29  -48 31  |                                         |
|                 {3} | 16  48  0   |                                         |
|                 {3} | -49 40  0   |                                         |
|                 {3} | 28  37  -31 |                                         |
|                 {3} | 35  0   48  |                                         |
|                 {3} | 46  -48 -30 |                                         |
|                 {3} | 1   0   -11 |                                         |
|                 {3} | -29 -18 -47 |                                         |
|                 {3} | 0   17  49  |                                         |
|                 {3} | 0   1   44  |                                         |
|                 {3} | -10 48  0   |                                         |
|                 {3} | -15 0   48  |                                         |
|                 {3} | -10 -37 -30 |                                         |
|                 {3} | -49 14  0   |                                         |
|                 {3} | 28  22  -47 |                                         |
|                 {3} | 0   18  49  |                                         |
|                 {3} | 46  18  -40 |                                         |
|                 {3} | 1   0   40  |                                         |
|                 {3} | 0   1   45  |                                         |
|                 {3} | 10  22  40  |                                         |
|                                                                             |
|           15                   1                                            |
|      4 : S   <--------------- S  : 3                                        |
|                 {4} | -31 |                                                 |
|                 {4} | -48 |                                                 |
|                 {4} | -29 |                                                 |
|                 {4} | -48 |                                                 |
|                 {4} | 30  |                                                 |
|                 {4} | -37 |                                                 |
|                 {4} | 47  |                                                 |
|                 {4} | -49 |                                                 |
|                 {4} | 28  |                                                 |
|                 {4} | -18 |                                                 |
|                 {4} | 46  |                                                 |
|                 {4} | 1   |                                                 |
|                 {4} | 40  |                                                 |
|                 {4} | -22 |                                                 |
|                 {4} | 10  |                                                 |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|1)                                                                           |
+-----------------------------------------------------------------------------+
|i14 : isCommutative f3                                                       |
|                                                                             |
|o14 = true                                                                   |
+-----------------------------------------------------------------------------+
|i15 : assert(degree f3 == 1)                                                 |
+-----------------------------------------------------------------------------+
|i16 : part1 = dd^D_3 * f3_2                                                  |
|                                                                             |
|o16 = {2} | 16a+35b  48a+35c  48b-16c  |                                     |
|      {2} | -49a+17b 40a+17c  40b+49c  |                                     |
|      {2} | -44a+b   -11a+c   -11b+44c |                                     |
|      {2} | 26b      26c      0        |                                     |
|      {2} | -16a+15b -48a+15c -48b+16c |                                     |
|      {2} | 49a-18b  -40a-18c -40b-49c |                                     |
|      {2} | -10a+35b 48a+35c  48b+10c  |                                     |
|      {2} | -50a     0        50c      |                                     |
|      {2} | 45a-b    11a-c    11b-45c  |                                     |
|      {2} | -49a+17b 14a+17c  14b+49c  |                                     |
|      {2} | -44a+b   40a+c    40b+44c  |                                     |
|      {2} | 0        a        b        |                                     |
|      {2} | -10a-15b 48a-15c  48b+10c  |                                     |
|      {2} | -49a+18b 14a+18c  14b+49c  |                                     |
|      {2} | -45a+b   40a+c    40b+45c  |                                     |
|                                                                             |
|              15       3                                                     |
|o16 : Matrix S   <--- S                                                      |
+-----------------------------------------------------------------------------+
|i17 : part2 = f3_1 * dd^C_2                                                  |
|                                                                             |
|o17 = {2} | -16a-35b -48a-35c -48b+16c |                                     |
|      {2} | 49a-17b  -40a-17c -40b-49c |                                     |
|      {2} | 44a-b    11a-c    11b-44c  |                                     |
|      {2} | -26b     -26c     0        |                                     |
|      {2} | 16a-15b  48a-15c  48b-16c  |                                     |
|      {2} | -49a+18b 40a+18c  40b+49c  |                                     |
|      {2} | 10a-35b  -48a-35c -48b-10c |                                     |
|      {2} | 50a      0        -50c     |                                     |
|      {2} | -45a+b   -11a+c   -11b+45c |                                     |
|      {2} | 49a-17b  -14a-17c -14b-49c |                                     |
|      {2} | 44a-b    -40a-c   -40b-44c |                                     |
|      {2} | 0        -a       -b       |                                     |
|      {2} | 10a+15b  -48a+15c -48b-10c |                                     |
|      {2} | 49a-18b  -14a-18c -14b-49c |                                     |
|      {2} | 45a-b    -40a-c   -40b-45c |                                     |
|                                                                             |
|              15       3                                                     |
|o17 : Matrix S   <--- S                                                      |
+-----------------------------------------------------------------------------+
|i18 : assert(part1 + part2 == 0)                                             |
+-----------------------------------------------------------------------------+

If the debugLevel (Macaulay2Doc), is greater than zero, then
the location of the first failure of commutativity is displayed.

+---------------------------------------------+
|i19 : f4 = randomComplexMap(D, C)            |
|                                             |
|           1             1                   |
|o19 = 0 : S  <--------- S  : 0               |
|                | 7 |                        |
|                                             |
|           6                           3     |
|      1 : S  <----------------------- S  : 1 |
|                {1} | 30  8   -18 |          |
|                {1} | 13  8   42  |          |
|                {1} | -17 -29 23  |          |
|                {1} | -13 30  -28 |          |
|                {1} | 3   -46 15  |          |
|                {1} | -41 49  18  |          |
|                                             |
|           15                           3    |
|      2 : S   <----------------------- S  : 2|
|                 {2} | -16 -28 30  |         |
|                 {2} | -46 47  4   |         |
|                 {2} | 12  -28 22  |         |
|                 {2} | -18 6   5   |         |
|                 {2} | 27  -9  -20 |         |
|                 {2} | -21 -33 -13 |         |
|                 {2} | 23  28  -29 |         |
|                 {2} | -37 -29 15  |         |
|                 {2} | -23 26  -4  |         |
|                 {2} | 44  5   12  |         |
|                 {2} | -39 -37 3   |         |
|                 {2} | 20  -33 9   |         |
|                 {2} | 19  -28 -2  |         |
|                 {2} | 0   42  20  |         |
|                 {2} | -47 44  -26 |         |
|                                             |
|           20                   1            |
|      3 : S   <--------------- S  : 3        |
|                 {3} | 33  |                 |
|                 {3} | 16  |                 |
|                 {3} | 10  |                 |
|                 {3} | 31  |                 |
|                 {3} | 28  |                 |
|                 {3} | -6  |                 |
|                 {3} | 21  |                 |
|                 {3} | -30 |                 |
|                 {3} | -4  |                 |
|                 {3} | -14 |                 |
|                 {3} | -33 |                 |
|                 {3} | -42 |                 |
|                 {3} | -44 |                 |
|                 {3} | -5  |                 |
|                 {3} | -16 |                 |
|                 {3} | -35 |                 |
|                 {3} | -39 |                 |
|                 {3} | -4  |                 |
|                 {3} | -24 |                 |
|                 {3} | -32 |                 |
|                                             |
|o19 : ComplexMap                             |
+---------------------------------------------+
|i20 : isCommutative f4                       |
|                                             |
|o20 = false                                  |
+---------------------------------------------+
|i21 : debugLevel = 1                         |
|                                             |
|o21 = 1                                      |
+---------------------------------------------+
|i22 : isCommutative f4                       |
|-- block (1, 0) fails to commute             |
|                                             |
|o22 = false                                  |
+---------------------------------------------+

See also
========

  * isComplexMorphism -- whether a
    complex map is a morphism of complexes
  * randomComplexMap -- a
    random map of chain complexes
  * freeResolution -- compute a free resolution of a
    module or ideal

Ways to use this method:
========================

  * isCommutative(ComplexMap) -- whether
    a complex map commutes with the differentials

isComplexMorphism(ComplexMap) -- whether a complex map is a morphism of complexes
*********************************************************************************

Synopsis
========

  * Function: isComplexMorphism,
  * Usage:
        isComplexMorphism f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when $f$
        commutes with the differentials and has degree $0$

Description
===========

For a complex map $f : C \to D$ of degree $d$, this method checks whether $d =
0$ and, for all $i$, we have $dd^D_{i+d} * f_i = (-1)^d * (f_{i-1} * dd^C_i)$.

We first construct a random complex morphism.

+-----------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c];                                                |
+-----------------------------------------------------------------------+
|i2 : C = freeResolution coker vars S                                   |
|                                                                       |
|      1      3      3      1                                           |
|o2 = S  <-- S  <-- S  <-- S                                            |
|                                                                       |
|     0      1      2      3                                            |
|                                                                       |
|o2 : Complex                                                           |
+-----------------------------------------------------------------------+
|i3 : D = C ** C                                                        |
|                                                                       |
|      1      6      15      20      15      6      1                   |
|o3 = S  <-- S  <-- S   <-- S   <-- S   <-- S  <-- S                    |
|                                                                       |
|     0      1      2       3       4       5      6                    |
|                                                                       |
|o3 : Complex                                                           |
+-----------------------------------------------------------------------+
|i4 : f1 = randomComplexMap(D, C, Boundary => true, InternalDegree => 1)|
|                                                                       |
|          1                       1                                    |
|o4 = 0 : S  <------------------- S  : 0                                |
|               | -5a-17b-11c |                                         |
|                                                                       |
|          6                                                      3     |
|     1 : S  <-------------------------------------------------- S  : 1 |
|               {1} | 2a-28b+50c   -28a+39b-13c -23a-b-48c   |          |
|               {1} | 26a-16b+42c  41a-20b-19c  23a-11b-16c  |          |
|               {1} | 18a+31b+19c  -5a-23b-48c  50a-38b-19c  |          |
|               {1} | -7a-25b-38c  28a-36b+16c  23a-b-4c     |          |
|               {1} | 10a+16b-21c  -49a+3b-41c  -21a+11b+32c |          |
|               {1} | -41a+49b-19c 2a-29b+48c   -3a+5b+8c    |          |
|                                                                       |
|          15                                                      3    |
|     2 : S   <-------------------------------------------------- S  : 2|
|                {2} | 33a+7b-12c   16a-20b+41c  -39a-42b+11c |         |
|                {2} | 30a+40b-7c   -2a+46b+14c  4a+20b+35c   |         |
|                {2} | -3a-39b+2c   -39a-30b+47c 22a-34b-43c  |         |
|                {2} | -28a+39b+9c  -23a+32b+46c 47b-47c      |         |
|                {2} | 8a-25b+14c   7a-33b+16c   39a+3b-11c   |         |
|                {2} | -35a+8b+10c  -49a-20b+7c  -4a+33b+22c  |         |
|                {2} | 31a+35b-8c   -17a-20b-19c -8a-43b+4c   |         |
|                {2} | -28a+16b-29c 42a+43c      -39a-11b-37c |         |
|                {2} | 15a+8b-39c   -25a+30b     -25a-4b-16c  |         |
|                {2} | 8a-14b-7c    3a+33b-36c   -22a+41b+48c |         |
|                {2} | -24a+49b+2c  -37a+44b+5c  -19a+7b-24c  |         |
|                {2} | 50a+18b      43a+23b-19c  49a-38b+48c  |         |
|                {2} | -18a+42c     -38a+33b+34c -8a-2b-22c   |         |
|                {2} | 10a-b-10c    46b-45c      -22a-32b-6c  |         |
|                {2} | -25a+39c     -45a+44b-21c -50a+12b-25c |         |
|                                                                       |
|          20                            1                              |
|     3 : S   <------------------------ S  : 3                          |
|                {3} | 9a+22b+11c   |                                   |
|                {3} | -39a-32b+46c |                                   |
|                {3} | 4a+9b-28c    |                                   |
|                {3} | 13a+32b+c    |                                   |
|                {3} | -26a+20b-3c  |                                   |
|                {3} | 22a-24b+22c  |                                   |
|                {3} | -49a+30b-47c |                                   |
|                {3} | -11a+48b-23c |                                   |
|                {3} | -8a+15b-7c   |                                   |
|                {3} | 43a-39b+2c   |                                   |
|                {3} | -8a+29c      |                                   |
|                {3} | 36a-33b-47c  |                                   |
|                {3} | -3a+49b+15c  |                                   |
|                {3} | -22a+33b-37c |                                   |
|                {3} | -30a+19b-13c |                                   |
|                {3} | 41a-17b-10c  |                                   |
|                {3} | 16a+20b+30c  |                                   |
|                {3} | -28a-44b-18c |                                   |
|                {3} | -6a+39b+39c  |                                   |
|                {3} | 35a-36b+27c  |                                   |
|                                                                       |
|o4 : ComplexMap                                                        |
+-----------------------------------------------------------------------+
|i5 : isComplexMorphism f1                                              |
|                                                                       |
|o5 = true                                                              |
+-----------------------------------------------------------------------+
|i6 : assert(degree f1 == 0)                                            |
+-----------------------------------------------------------------------+
|i7 : assert isNullHomotopic f1                                         |
+-----------------------------------------------------------------------+
|i8 : assert(source f1 == C and target f1 == D)                         |
+-----------------------------------------------------------------------+

We next generate a complex morphism that (likely) induces a nontrivial map on
homology.

+-----------------------------------------------+
|i9 : f2 = randomComplexMap(D, C, Cycle => true)|
|                                               |
|          1               1                    |
|o9 = 0 : S  <----------- S  : 0                |
|               | -40 |                         |
|                                               |
|          6                           3        |
|     1 : S  <----------------------- S  : 1    |
|               {1} | -44 -48 22  |             |
|               {1} | 41  2   1   |             |
|               {1} | 18  -1  -9  |             |
|               {1} | 4   48  -22 |             |
|               {1} | -41 -42 -1  |             |
|               {1} | -18 1   -31 |             |
|                                               |
|          15                           3       |
|     2 : S   <----------------------- S  : 2   |
|                {2} | -11 -3  -35 |            |
|                {2} | -41 22  6   |            |
|                {2} | -49 -25 31  |            |
|                {2} | -48 22  0   |            |
|                {2} | 13  4   35  |            |
|                {2} | 40  -31 -6  |            |
|                {2} | 33  -3  -13 |            |
|                {2} | -41 0   1   |            |
|                {2} | 31  25  -40 |            |
|                {2} | -41 -35 -47 |            |
|                {2} | -49 35  29  |            |
|                {2} | 0   -18 1   |            |
|                {2} | -9  -4  -13 |            |
|                {2} | -40 35  -47 |            |
|                {2} | -31 35  -2  |            |
|                                               |
|          20                   1               |
|     3 : S   <--------------- S  : 3           |
|                {3} | -9  |                    |
|                {3} | -35 |                    |
|                {3} | 6   |                    |
|                {3} | 40  |                    |
|                {3} | 3   |                    |
|                {3} | -31 |                    |
|                {3} | 25  |                    |
|                {3} | -2  |                    |
|                {3} | -41 |                    |
|                {3} | -49 |                    |
|                {3} | -13 |                    |
|                {3} | 4   |                    |
|                {3} | 30  |                    |
|                {3} | -47 |                    |
|                {3} | 27  |                    |
|                {3} | -40 |                    |
|                {3} | 37  |                    |
|                {3} | -35 |                    |
|                {3} | -31 |                    |
|                {3} | -39 |                    |
|                                               |
|o9 : ComplexMap                                |
+-----------------------------------------------+
|i10 : isComplexMorphism f2                     |
|                                               |
|o10 = true                                     |
+-----------------------------------------------+
|i11 : assert(degree f2 == 0)                   |
+-----------------------------------------------+
|i12 : assert isComplexMorphism f2              |
+-----------------------------------------------+

When the degree is non-zero, the map is not a complex morphism. If the
debugLevel (Macaulay2Doc), is greater than zero, then information
about the failure is displayed.

+-----------------------------------------------------------------------------+
|i13 : f3 = randomComplexMap(D, C, Cycle => true, Degree=>1, InternalDegree =>|
|                                                                             |
|           6                   1                                             |
|o13 = 1 : S  <--------------- S  : 0                                         |
|                {1} | -26 |                                                  |
|                {1} | -50 |                                                  |
|                {1} | 1   |                                                  |
|                {1} | 26  |                                                  |
|                {1} | 50  |                                                  |
|                {1} | -1  |                                                  |
|                                                                             |
|           15                           3                                    |
|      2 : S   <----------------------- S  : 1                                |
|                 {2} | 35  -16 -48 |                                         |
|                 {2} | 17  49  -40 |                                         |
|                 {2} | 1   44  11  |                                         |
|                 {2} | 26  0   0   |                                         |
|                 {2} | 15  16  48  |                                         |
|                 {2} | -18 -49 40  |                                         |
|                 {2} | 35  10  -48 |                                         |
|                 {2} | 0   50  0   |                                         |
|                 {2} | -1  -45 -11 |                                         |
|                 {2} | 17  49  -14 |                                         |
|                 {2} | 1   44  -40 |                                         |
|                 {2} | 0   0   -1  |                                         |
|                 {2} | -15 10  -48 |                                         |
|                 {2} | 18  49  -14 |                                         |
|                 {2} | 1   45  -40 |                                         |
|                                                                             |
|           20                           3                                    |
|      3 : S   <----------------------- S  : 2                                |
|                 {3} | 29  -48 31  |                                         |
|                 {3} | 16  48  0   |                                         |
|                 {3} | -49 40  0   |                                         |
|                 {3} | 28  37  -31 |                                         |
|                 {3} | 35  0   48  |                                         |
|                 {3} | 46  -48 -30 |                                         |
|                 {3} | 1   0   -11 |                                         |
|                 {3} | -29 -18 -47 |                                         |
|                 {3} | 0   17  49  |                                         |
|                 {3} | 0   1   44  |                                         |
|                 {3} | -10 48  0   |                                         |
|                 {3} | -15 0   48  |                                         |
|                 {3} | -10 -37 -30 |                                         |
|                 {3} | -49 14  0   |                                         |
|                 {3} | 28  22  -47 |                                         |
|                 {3} | 0   18  49  |                                         |
|                 {3} | 46  18  -40 |                                         |
|                 {3} | 1   0   40  |                                         |
|                 {3} | 0   1   45  |                                         |
|                 {3} | 10  22  40  |                                         |
|                                                                             |
|           15                   1                                            |
|      4 : S   <--------------- S  : 3                                        |
|                 {4} | -31 |                                                 |
|                 {4} | -48 |                                                 |
|                 {4} | -29 |                                                 |
|                 {4} | -48 |                                                 |
|                 {4} | 30  |                                                 |
|                 {4} | -37 |                                                 |
|                 {4} | 47  |                                                 |
|                 {4} | -49 |                                                 |
|                 {4} | 28  |                                                 |
|                 {4} | -18 |                                                 |
|                 {4} | 46  |                                                 |
|                 {4} | 1   |                                                 |
|                 {4} | 40  |                                                 |
|                 {4} | -22 |                                                 |
|                 {4} | 10  |                                                 |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|1)                                                                           |
+-----------------------------------------------------------------------------+
|i14 : assert(degree f3 == 1)                                                 |
+-----------------------------------------------------------------------------+
|i15 : isComplexMorphism f3                                                   |
|                                                                             |
|o15 = false                                                                  |
+-----------------------------------------------------------------------------+
|i16 : debugLevel = 1                                                         |
|                                                                             |
|o16 = 1                                                                      |
+-----------------------------------------------------------------------------+
|i17 : isComplexMorphism f3                                                   |
|-- the complex map has non-zero degree                                       |
|                                                                             |
|o17 = false                                                                  |
+-----------------------------------------------------------------------------+
|i18 : assert isCommutative f3                                                |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i19 : f4 = randomComplexMap(D, C)                                            |
| -- (basis,List,List,Module) with Strategy => Torsion                        |
| -- (basis,List,List,Module) with Strategy => Default                        |
| -- (inducedMap,Module,Module,Matrix) with Strategy =>                       |
| -- (inducedMap,Module,Module,Matrix) with Strategy =>                       |
| -- (inducedMap,Module,Module,Matrix) with Strategy =>                       |
| -- (inducedMap,Module,Module,Matrix) with Strategy =>                       |
|                                                                             |
|           1             1                                                   |
|o19 = 0 : S  <--------- S  : 0                                               |
|                | 7 |                                                        |
|                                                                             |
|           6                           3                                     |
|      1 : S  <----------------------- S  : 1                                 |
|                {1} | 30  8   -18 |                                          |
|                {1} | 13  8   42  |                                          |
|                {1} | -17 -29 23  |                                          |
|                {1} | -13 30  -28 |                                          |
|                {1} | 3   -46 15  |                                          |
|                {1} | -41 49  18  |                                          |
|                                                                             |
|           15                           3                                    |
|      2 : S   <----------------------- S  : 2                                |
|                 {2} | -16 -28 30  |                                         |
|                 {2} | -46 47  4   |                                         |
|                 {2} | 12  -28 22  |                                         |
|                 {2} | -18 6   5   |                                         |
|                 {2} | 27  -9  -20 |                                         |
|                 {2} | -21 -33 -13 |                                         |
|                 {2} | 23  28  -29 |                                         |
|                 {2} | -37 -29 15  |                                         |
|                 {2} | -23 26  -4  |                                         |
|                 {2} | 44  5   12  |                                         |
|                 {2} | -39 -37 3   |                                         |
|                 {2} | 20  -33 9   |                                         |
|                 {2} | 19  -28 -2  |                                         |
|                 {2} | 0   42  20  |                                         |
|                 {2} | -47 44  -26 |                                         |
|                                                                             |
|           20                   1                                            |
|      3 : S   <--------------- S  : 3                                        |
|                 {3} | 33  |                                                 |
|                 {3} | 16  |                                                 |
|                 {3} | 10  |                                                 |
|                 {3} | 31  |                                                 |
|                 {3} | 28  |                                                 |
|                 {3} | -6  |                                                 |
|                 {3} | 21  |                                                 |
|                 {3} | -30 |                                                 |
|                 {3} | -4  |                                                 |
|                 {3} | -14 |                                                 |
|                 {3} | -33 |                                                 |
|                 {3} | -42 |                                                 |
|                 {3} | -44 |                                                 |
|                 {3} | -5  |                                                 |
|                 {3} | -16 |                                                 |
|                 {3} | -35 |                                                 |
|                 {3} | -39 |                                                 |
|                 {3} | -4  |                                                 |
|                 {3} | -24 |                                                 |
|                 {3} | -32 |                                                 |
|                                                                             |
|o19 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|from -*Function[/usr/share/Macaulay2/Core/basis.m2:270:34-276:28]*-          |
|from basisDefaultStrategy                                                    |
| Default from -*Function[/usr/share/Macaulay2/Core/matrix.m2:636:86-644:20]*-|
| Default from -*Function[/usr/share/Macaulay2/Core/matrix.m2:636:86-644:20]*-|
| Default from -*Function[/usr/share/Macaulay2/Core/matrix.m2:636:86-644:20]*-|
| Default from -*Function[/usr/share/Macaulay2/Core/matrix.m2:636:86-644:20]*-|
+-----------------------------------------------------------------------------+
|i20 : assert(degree f4 == 0)                                                 |
+-----------------------------------------------------------------------------+
|i21 : debugLevel = 0                                                         |
|                                                                             |
|o21 = 0                                                                      |
+-----------------------------------------------------------------------------+
|i22 : isComplexMorphism f4                                                   |
|                                                                             |
|o22 = false                                                                  |
+-----------------------------------------------------------------------------+
|i23 : debugLevel = 1                                                         |
|                                                                             |
|o23 = 1                                                                      |
+-----------------------------------------------------------------------------+
|i24 : isComplexMorphism f4                                                   |
|-- block (1, 0) fails to commute                                             |
|                                                                             |
|o24 = false                                                                  |
+-----------------------------------------------------------------------------+

See also
========

  * isCommutative(ComplexMap) -- whether
    a complex map commutes with the differentials
  * randomComplexMap -- a
    random map of chain complexes
  * freeResolution -- compute a free resolution of a
    module or ideal

Ways to use this method:
========================

  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes

isExact -- whether a complex is exact
*************************************

Synopsis
========

  * Usage:
        isExact C
        isExact(C, lo, hi)
  * Inputs:
      * C, a complex,
      * lo, a number (Macaulay2Doc), or -infinity
      * hi, a number (Macaulay2Doc), or infinity
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when C is
        exact

Description
===========

The complex $C$ is exact if and only if the homology group $H^i(C)$ is the zero
module, for all $i$.  If bounds are given, then true is returned if $H^i(C) =
0$ for all $lo \le i \le hi$.

A resolution $C$ is an exact complex except in homological degree 0. The
augmented complex $C'$ is exact everywhere.

+-------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..d];                                                   |
+-------------------------------------------------------------------------+
|i2 : I = monomialCurveIdeal(S, {1,3,4})                                  |
|                                                                         |
|                        3      2     2    2    3    2                    |
|o2 = ideal (b*c - a*d, c  - b*d , a*c  - b d, b  - a c)                  |
|                                                                         |
|o2 : Ideal of S                                                          |
+-------------------------------------------------------------------------+
|i3 : C = freeResolution I                                                |
|                                                                         |
|      1      4      4      1                                             |
|o3 = S  <-- S  <-- S  <-- S                                              |
|                                                                         |
|     0      1      2      3                                              |
|                                                                         |
|o3 : Complex                                                             |
+-------------------------------------------------------------------------+
|i4 : prune HH C                                                          |
|                                                                         |
|o4 = cokernel | bc-ad c3-bd2 ac2-b2d b3-a2c |                            |
|                                                                         |
|     0                                                                   |
|                                                                         |
|o4 : Complex                                                             |
+-------------------------------------------------------------------------+
|i5 : assert not isExact C                                                |
+-------------------------------------------------------------------------+
|i6 : assert isExact(C, 1, infinity)                                      |
+-------------------------------------------------------------------------+
|i7 : C' = cone inducedMap(complex(S^1/I), C)[1]                          |
|                                                                         |
|                                                   1      4      4      1|
|o7 = cokernel | bc-ad c3-bd2 ac2-b2d b3-a2c | <-- S  <-- S  <-- S  <-- S |
|                                                                         |
|     -1                                           0      1      2      3 |
|                                                                         |
|o7 : Complex                                                             |
+-------------------------------------------------------------------------+
|i8 : prune HH C'                                                         |
|                                                                         |
|o8 = 0                                                                   |
|                                                                         |
|     0                                                                   |
|                                                                         |
|o8 : Complex                                                             |
+-------------------------------------------------------------------------+
|i9 : assert isExact C'                                                   |
+-------------------------------------------------------------------------+

See also
========

  * HH Complex -- homology of a complex
  * cone (Macaulay2Doc) -- mapping cone of a chain map
  * freeResolution -- compute a free resolution of a
    module or ideal
  * prune (Macaulay2Doc) -- prune, e.g., compute a minimal
    presentation

Ways to use isExact :
=====================

  * "isExact(Complex)"
  * "isExact(Complex,InfiniteNumber,InfiniteNumber)"
  * "isExact(Complex,InfiniteNumber,Number)"
  * "isExact(Complex,Number,InfiniteNumber)"
  * "isExact(Complex,Number,Number)"

For the programmer
==================

The object isExact, is a method function (Macaulay2Doc).

isFree(Complex) -- whether a complex consists of free modules
*************************************************************

Synopsis
========

  * Function: isFree,
  * Usage:
        isFree C
  * Inputs:
      * C, a complex,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when each
        $C_i$ is a free module

Description
===========

This method checks whether the given representation of each module $C_i$ is
free. To determine whether the complex $C$ is isomorphic to a free complex, use
prune.

The following example demonstrates that the presentation of a module might not
reveal the property of being free.

+--------------------------------+
|i1 : S = ZZ/101[a,b];           |
+--------------------------------+
|i2 : M = kernel vars S          |
|                                |
|o2 = image {1} | -b |           |
|           {1} | a  |           |
|                                |
|                             2  |
|o2 : S-module, submodule of S   |
+--------------------------------+
|i3 : assert not isFreeModule M  |
+--------------------------------+
|i4 : assert isFreeModule prune M|
+--------------------------------+

By definition, a free resolution $C$ consists of free modules. In contrast, the
augmented complex $C'$ might or might not consist of free modules.

+--------------------------------------------------------+
|i5 : C = freeResolution M                               |
|                                                        |
|      1                                                 |
|o5 = S                                                  |
|                                                        |
|     0                                                  |
|                                                        |
|o5 : Complex                                            |
+--------------------------------------------------------+
|i6 : assert isFree C                                    |
+--------------------------------------------------------+
|i7 : C' = cone map(complex M, C, i -> map(M, C_0, 1))[1]|
|                                                        |
|                           1                            |
|o7 = image {1} | -b | <-- S                             |
|           {1} | a  |                                   |
|                          0                             |
|     -1                                                 |
|                                                        |
|o7 : Complex                                            |
+--------------------------------------------------------+
|i8 : isWellDefined C'                                   |
|                                                        |
|o8 = true                                               |
+--------------------------------------------------------+
|i9 : assert not isFree C'                               |
+--------------------------------------------------------+
|i10 : prune C'                                          |
|                                                        |
|       1      1                                         |
|o10 = S  <-- S                                          |
|                                                        |
|      -1     0                                          |
|                                                        |
|o10 : Complex                                           |
+--------------------------------------------------------+
|i11 : assert isFree prune C'                            |
+--------------------------------------------------------+

See also
========

  * isFreeModule (Macaulay2Doc) -- whether something is a
    free module
  * freeResolution -- compute a free resolution of a
    module or ideal
  * prune(Complex) -- minimal
    presentation of all terms in a complex

Ways to use this method:
========================

  * isFree(Complex) -- whether a complex consists
    of free modules

isHomogeneous(Complex) -- whether a complex is homogeneous
**********************************************************

Synopsis
========

  * Function: isHomogeneous (Macaulay2Doc),
  * Usage:
        isHomogeneous C
  * Inputs:
      * C, a complex,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when C is a
        homogeneous (i.e. graded) complex

Description
===========

A complex is homogeneous (graded) if the base ring is graded, all of the
component objects are graded, and all the component maps are graded of degree
zero.

+------------------------------------------------+
|i1 : S = ZZ/101[a,b,c,d];                       |
+------------------------------------------------+
|i2 : I = minors(2, matrix{{a,b,c},{b,c,d}})     |
|                                                |
|               2                        2       |
|o2 = ideal (- b  + a*c, - b*c + a*d, - c  + b*d)|
|                                                |
|o2 : Ideal of S                                 |
+------------------------------------------------+
|i3 : C = freeResolution (S^1/I)                 |
|                                                |
|      1      3      2                           |
|o3 = S  <-- S  <-- S                            |
|                                                |
|     0      1      2                            |
|                                                |
|o3 : Complex                                    |
+------------------------------------------------+
|i4 : isHomogeneous C                            |
|                                                |
|o4 = true                                       |
+------------------------------------------------+
|i5 : J = minors(2, matrix{{a,b,c},{b,c,d^2}})   |
|                                                |
|               2           2           2    2   |
|o5 = ideal (- b  + a*c, a*d  - b*c, b*d  - c )  |
|                                                |
|o5 : Ideal of S                                 |
+------------------------------------------------+
|i6 : D = freeResolution (S^1/J)                 |
|                                                |
|      1      3      2                           |
|o6 = S  <-- S  <-- S                            |
|                                                |
|     0      1      2                            |
|                                                |
|o6 : Complex                                    |
+------------------------------------------------+
|i7 : isHomogeneous D                            |
|                                                |
|o7 = false                                      |
+------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * isHomogeneous (Macaulay2Doc) -- whether something is
    homogeneous (graded)
  * isHomogeneous(ComplexMap) -- whether
    a map of complexes is homogeneous

Ways to use this method:
========================

  * isHomogeneous(Complex) -- whether a
    complex is homogeneous

isHomogeneous(ComplexMap) -- whether a map of complexes is homogeneous
**********************************************************************

Synopsis
========

  * Function: isHomogeneous (Macaulay2Doc),
  * Usage:
        isHomogeneous f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when $f_i$
        is homogeneous, for all $i$

Description
===========

A map of complexes $f \colon C \to D$ is homogeneous (graded) if its underlying
ring is graded, and all the component maps $f_i \colon C_i \to D_{d+i}$ are
graded of degree zero, where $f$ has degree $d$.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c,d];                                                    |
+-----------------------------------------------------------------------------+
|i2 : I = minors(2, matrix{{a,b,c},{b,c,d}})                                  |
|                                                                             |
|               2                        2                                    |
|o2 = ideal (- b  + a*c, - b*c + a*d, - c  + b*d)                             |
|                                                                             |
|o2 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i3 : C = freeResolution (S^1/I)                                              |
|                                                                             |
|      1      3      2                                                        |
|o3 = S  <-- S  <-- S                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : assert isHomogeneous dd^C                                               |
+-----------------------------------------------------------------------------+
|i5 : f = randomComplexMap(C, C, Degree => -1)                                |
|                                                                             |
|                    1                                                        |
|o5 = -1 : 0 <----- S  : 0                                                    |
|               0                                                             |
|                                                                             |
|          1                                                                  |
|     0 : S  <----------------------------------------------------------------|
|               | 24a2-36ab+19b2-30ac+19bc-29c2-29ad-10bd-8cd-22d2 -29a2-24ab+|
|                                                                             |
|          3                                                2                 |
|     1 : S  <-------------------------------------------- S  : 2             |
|               {2} | 45a-34b-48c-47d -17a-11b+48c+36d |                      |
|               {2} | 47a+19b-16c+7d  35a+11b-38c+33d  |                      |
|               {2} | 15a-23b+39c+43d 40a+11b+46c-28d  |                      |
|                                                                             |
|o5 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|39b2-38ac+21bc+19c2-16ad+34bd-47cd-39d2 -18a2-13ab-28b2-43ac-47bc+2c2-15ad+38|
|-----------------------------------------------------------------------------|
|                  3                                                          |
|---------------- S  : 1                                                      |
|bd+16cd+22d2 |                                                               |
+-----------------------------------------------------------------------------+
|i6 : assert isHomogeneous f                                                  |
+-----------------------------------------------------------------------------+
|i7 : f = randomComplexMap(C, C, InternalDegree => 2)                         |
|                                                                             |
|          1                                                        1         |
|o7 = 0 : S  <---------------------------------------------------- S  : 0     |
|               | a2-3ab-23b2+22ac-7bc+29c2-47ad+2bd-47cd+15d2 |              |
|                                                                             |
|          3                                                                  |
|     1 : S  <----------------------------------------------------------------|
|               {2} | -37a2-13ab-18b2-10ac+39bc-22c2+30ad+27bd+32cd-9d2 13a2-2|
|               {2} | -32a2-20ab-48b2+24ac-15bc-30ad+39bd+33cd-49d2     -22a2-|
|               {2} | -33a2-19ab+44b2+17ac-39bc+9c2-20ad+36bd-39cd+4d2  40a2+3|
|                                                                             |
|          2                                                                  |
|     2 : S  <----------------------------------------------------------------|
|               {3} | 8a2-29ab+49b2+30ac-18bc+23c2-46ad+42bd-28cd+15d2  44a2-3|
|               {3} | 18a2-16ab-18b2-46ac+27bc+23c2+12ad-21bd-37cd-23d2 -9a2-3|
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|6ab-11b2+22ac-8bc-8c2-49ad+43bd+36cd-3d2  -47a2+27ab-35b2-40ac-31bc-31c2+37ad|
|30ab-28b2+41ac-6bc-9c2+16ad+35bd-35cd+6d2 -48a2+30ab-49b2-37ac+28bc+46c2+47ad|
|ab-2b2-31ac-41bc-13c2+25ad-49bd+4cd+30d2  -22a2+10ab+13b2+7ac-17bc+3c2+30ad-1|
|                                                                             |
|                                                2                            |
|---------------------------------------------- S  : 2                        |
|9ab+20ac-47bc+47c2+19ad-28bd-28cd+6d2      |                                 |
|3ab+26b2+28ac+5bc-33c2-29ad-37bd-28cd+42d2 |                                 |
|-----------------------------------------------------------------------------|
|                     3                                                       |
|------------------- S  : 1                                                   |
|-39bd-48cd-29d2 |                                                            |
|-18bd+cd+40d2   |                                                            |
|3bd-41cd+8d2    |                                                            |
+-----------------------------------------------------------------------------+
|i8 : assert isHomogeneous f                                                  |
+-----------------------------------------------------------------------------+

A map of chain complexes may be homogeneous even if the source or the target is
not homogeneous.

+-----------------------------------------------------------------------------+
|i9 : phi = map(S, S, {1,b,c,d})                                              |
|                                                                             |
|o9 = map (S, S, {1, b, c, d})                                                |
|                                                                             |
|o9 : RingMap S <--- S                                                        |
+-----------------------------------------------------------------------------+
|i10 : D = phi C                                                              |
|                                                                             |
|       1      3      2                                                       |
|o10 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o10 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i11 : dd^D                                                                   |
|                                                                             |
|           1                           3                                     |
|o11 = 0 : S  <----------------------- S  : 1                                 |
|                | b2-c bc-d c2-bd |                                          |
|                                                                             |
|           3                     2                                           |
|      1 : S  <----------------- S  : 2                                       |
|                {2} | -c d  |                                                |
|                {2} | b  -c |                                                |
|                {2} | -1 b  |                                                |
|                                                                             |
|o11 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i12 : assert not isHomogeneous dd^D                                          |
+-----------------------------------------------------------------------------+
|i13 : g = randomComplexMap(D, D, InternalDegree => 1)                        |
|                                                                             |
|           1                          1                                      |
|o13 = 0 : S  <---------------------- S  : 0                                  |
|                | 44a+30b+4c+22d |                                           |
|                                                                             |
|           3                                                               3 |
|      1 : S  <----------------------------------------------------------- S  |
|                {2} | 5a-20b-13c-29d 33a+16b+10c+31d -44a-5b-16c-35d  |      |
|                {2} | 15a-4b+12c+3d  28a-6b+21c-30d  -39a-4b-24c-32d  |      |
|                {2} | 9a-2b+20c-26d  -4a-14b-33c-42d -23a-18b+27c-45d |      |
|                                                                             |
|           2                                                2                |
|      2 : S  <-------------------------------------------- S  : 2            |
|                {3} | 18a-28b+42c-11d -38a-26b+28c-33d |                     |
|                {3} | 8a+42b+49c+5d   9a-7b-46c+2d     |                     |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|: 1                                                                          |
+-----------------------------------------------------------------------------+
|i14 : assert isHomogeneous g                                                 |
+-----------------------------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * isHomogeneous (Macaulay2Doc) -- whether something is
    homogeneous (graded)
  * isHomogeneous(ComplexMap) -- whether
    a map of complexes is homogeneous
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes

Ways to use this method:
========================

  * isHomogeneous(ComplexMap) -- whether
    a map of complexes is homogeneous

isNullHomotopic(ComplexMap) -- whether a map of complexes is null-homotopic
***************************************************************************

Synopsis
========

  * Function: isNullHomotopic,
  * Usage:
        isNullHomotopic f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when $f$ is
        null-homotopic

Description
===========

A map of chain complexes $f \colon C \to D$ is null-homotopic if there exists a
map of chain complexes $h : C \to D$ of degree $\deg(f)+1$, such that we have
the equality \[ f = \operatorname{dd}^D h + (-1)^{\deg(f)} h
\operatorname{dd}^C. \]

As a first example, we construct a map of chain complexes in which the null
homotopy is given by the identity.

+-------------------------------------------------------------------+
|i1 : R = ZZ/101[x,y,z];                                            |
+-------------------------------------------------------------------+
|i2 : M = cokernel matrix{{x,y,z^2}, {y^2,z,x^2}}                   |
|                                                                   |
|o2 = cokernel | x  y z2 |                                          |
|              | y2 z x2 |                                          |
|                                                                   |
|                            2                                      |
|o2 : R-module, quotient of R                                       |
+-------------------------------------------------------------------+
|i3 : C = complex {id_M}                                            |
|                                                                   |
|o3 = cokernel | x  y z2 | <-- cokernel | x  y z2 |                 |
|              | y2 z x2 |              | y2 z x2 |                 |
|                                                                   |
|     0                        1                                    |
|                                                                   |
|o3 : Complex                                                       |
+-------------------------------------------------------------------+
|i4 : assert isNullHomotopic id_C                                   |
+-------------------------------------------------------------------+
|i5 : h = nullHomotopy id_C                                         |
|                                                                   |
|o5 = 1 : cokernel | x  y z2 | <----------- cokernel | x  y z2 | : 0|
|                  | y2 z x2 |    | 1 0 |            | y2 z x2 |    |
|                                 | 0 1 |                           |
|                                                                   |
|     2 : 0 <----- cokernel | x  y z2 | : 1                         |
|              0            | y2 z x2 |                             |
|                                                                   |
|o5 : ComplexMap                                                    |
+-------------------------------------------------------------------+
|i6 : assert(h_0 == id_M)                                           |
+-------------------------------------------------------------------+
|i7 : assert isNullHomotopyOf(h, id_C)                              |
+-------------------------------------------------------------------+

A random map of chain complexes, arising as a boundary in the associated Hom
complex, is automatically null homotopic.

+-----------------------------------------------------------------------------+
|i8 : C = (freeResolution M) ** R^1/ideal(x^3, z^3-x)                         |
|                                                                             |
|o8 = cokernel | x3 z3-x 0  0    | <-- cokernel {2} | x3 z3-x 0  0    0  0    |
|              | 0  0    x3 z3-x |              {1} | 0  0    x3 z3-x 0  0    |
|                                               {2} | 0  0    0  0    x3 z3-x |
|     0                                                                       |
|                                      1                                      |
|                                                                             |
|o8 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|| <-- cokernel {5} | x3 z3-x 0  0    0  0    | <-- cokernel {7} | x3 z3-x 0  |
||              {7} | 0  0    x3 z3-x 0  0    |              {9} | 0  0    x3 |
||              {9} | 0  0    0  0    x3 z3-x |                               |
|                                                   3                         |
|      2                                                                      |
|-----------------------------------------------------------------------------|
|0    |                                                                       |
|z3-x |                                                                       |
+-----------------------------------------------------------------------------+
|i9 : f = randomComplexMap(C, C[1],                                           |
|                                                                             |
|o9 = -1 : 0 <----- cokernel | x3 z3                                          |
|               0            | 0  0                                           |
|                                                                             |
|     0 : cokernel | x3 z3-x 0  0                                             |
|                  | 0  0    x3 z3-x                                          |
|                                                                             |
|                                                                             |
|     1 : cokernel {2} | x3 z3-x 0                                            |
|                  {1} | 0  0    x3                                           |
|                  {2} | 0  0    0                                            |
|                                                                             |
|                                                                             |
|     2 : cokernel {5} | x3 z3-x 0                                            |
|                  {7} | 0  0    x3                                           |
|                  {9} | 0  0    0                                            |
|                                                                             |
|                                                                             |
|o9 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|Boundary => true)                                                            |
|                                                                             |
|-x 0  0    | : -1                                                            |
|   x3 z3-x |                                                                 |
|                                                                             |
| | <-------------------------------------------------------------------------|
| |    | 19xy+20y2-29yz-8z2-5x        -46y+30z 30x2-24xy-38y2-16yz+15z2-29x | |
|      | -8x2+48y2+19xz-10yz-29z2+36x 36y+7z   -33x2-29y2-24xz-38yz+20z2    | |
|                                                                             |
|0    0  0    | <-------------------------------------------------------------|
|z3-x 0  0    |    {2} | 2x2y-29y3+29xz-2x                                    |
|0    x3 z3-x |    {1} | 10x2y2-24xy3-38y4+29x2yz-16y3z+43y2z2+24x2z+38xyz+16x|
|                  {2} | 8x2y+18y3-18xz-8x                                    |
|                                                                             |
|0    0  0    | <-------------------------------------------------------------|
|z3-x 0  0    |    {5} | 21x2-34xy+47y2-19xz+39yz+18z2 -19x2y2+43xy3+47y4+16x2|
|0    x3 z3-x |    {7} | 13                            -16x2-22xy-48y2-45xz+32|
|                  {9} | 0                             -47                    |
|-----------------------------------------------------------------------------|
|- cokernel {2} | x3 z3-x 0  0    0  0    | : 0                               |
|           {1} | 0  0    x3 z3-x 0  0    |                                   |
|           {2} | 0  0    0  0    x3 z3-x |                                   |
|                                                                             |
|-----------------------------------------------------------------------------|
|                  25x2y3-39x2y2z-18x2yz2-34x2y+47xy2-19x2z+39xyz+18xz2       |
|z2+19x2-10xy-29xz -38x2y4-16x2y3z+9x2y2z2+34xy3z2-47y4z2+19x2y2-39xy3-18xy2z |
|                  -49x2y3-34xy4+47y5-19xy3z+39y4z+18y3z2+34x2yz-47xy2z+19x2z2|
|                                                                             |
|-------------------------------------- cokernel {7} | x3 z3-x 0  0    | : 2  |
|yz+15xy2z-38y3z-7x2z2+28xyz2-2y2z2 |            {9} | 0  0    x3 z3-x |      |
|yz-47z2                            |                                         |
|                                   |                                         |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
|             -47x2y5+38x2y4z+2x2y3z2+43x2y3+47xy4+15x2y2z-38xy3z+28x2yz2-2xy2|
|             -34x2y4z2-43xy5z2-47y6z2-15x2y4+38xy5-28x2y3z+2xy4z             |
|-39xyz2-18x2 34x2y5+43xy6+47y7+48x2y4z+15xy5z-38y6z+47x2y3z2+28xy4z2-2y5z2-43|
|-----------------------------------------------------------------------------|
|--------------------------------------- cokernel {5} | x3 z3-x 0  0    0     |
|z2                                  |            {7} | 0  0    x3 z3-x 0     |
|                                    |            {9} | 0  0    0  0    x3    |
|x2y3z-47xy4z-15x2y2z2+38xy3z2+2x2y2 |                                        |
|-----------------------------------------------------------------------------|
|0    | : 1                                                                   |
|0    |                                                                       |
|z3-x |                                                                       |
+-----------------------------------------------------------------------------+
|i10 : assert isNullHomotopic f                                               |
+-----------------------------------------------------------------------------+
|i11 : h = nullHomotopy f                                                     |
|                                                                             |
|o11 = 0 : cokernel | x3 z3-x 0  0    |                                       |
|                   | 0  0    x3 z3-x |                                       |
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | x3 z3-x 0  0                                        |
|                   {1} | 0  0    x3 z3-                                      |
|                   {2} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      2 : cokernel {5} | x3 z3-x 0  0                                        |
|                   {7} | 0  0    x3 z3-                                      |
|                   {9} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      3 : cokernel {7} | x3 z3-x 0  0                                        |
|                   {9} | 0  0    x3 z3-                                      |
|                                                                             |
|                                                                             |
|o11 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|<----------------------------------- cokernel | x3 z3-x 0  0    | : -1       |
|   | 24yz+46        -24y2-30     |            | 0  0    x3 z3-x |            |
|   | -2x2yz+24z2-36 2x2y2-24yz-7 |                                           |
|                                                                             |
|  0  0    | <--------------------------------------------------- cokernel {2}|
|x 0  0    |    {2} | 2x2y2+41               0 -29            |            {1}|
|  x3 z3-x |    {1} | -24y3+24xz+19x-10y-29z 0 -24x2y-38y-16z |            {2}|
|               {2} | -8                     0 -40            |               |
|                                                                             |
|  0  0    | <----------------------------------------------------------------|
|x 0  0    |    {5} | 43 9x2+34xy-47y2+19xz-39yz-18z2 -34x2y2-43xy3-47y4-48x2y|
|  x3 z3-x |    {7} | 0  0                            0                       |
|               {9} | 0  0                            47                      |
|                                                                             |
|  | <--------------------------------------------- cokernel {7} | x3 z3-x 0  |
|x |    {7} | 13 -16x2-22xy-48y2-45xz+32yz-47z2 |            {9} | 0  0    x3 |
|       {9} | 0  0                              |                             |
|-----------------------------------------------------------------------------|
| | x3 z3-x 0  0    0  0    | : 0                                             |
| | 0  0    x3 z3-x 0  0    |                                                 |
| | 0  0    0  0    x3 z3-x |                                                 |
|                                                                             |
|                                                                             |
|-------------------------------------- cokernel {5} | x3 z3-x 0  0    0  0   |
|z-15xy2z+38y3z-47x2z2-28xyz2+2y2z2 |            {7} | 0  0    x3 z3-x 0  0   |
|                                   |            {9} | 0  0    0  0    x3 z3-x|
|                                   |                                         |
|                                                                             |
|0    | : 2                                                                   |
|z3-x |                                                                       |
|-----------------------------------------------------------------------------|
|| : 1                                                                        |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i12 : assert isNullHomotopyOf(h, f)                                          |
+-----------------------------------------------------------------------------+
|i13 : g = randomComplexMap(C, C[1])                                          |
|                                                                             |
|o13 = -1 : 0 <----- cokernel | x3 z3-x                                       |
|                0            | 0  0                                          |
|                                                                             |
|      0 : cokernel | x3 z3-x 0  0    |                                       |
|                   | 0  0    x3 z3-x |                                       |
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | x3 z3-x 0  0                                        |
|                   {1} | 0  0    x3 z3-                                      |
|                   {2} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      2 : cokernel {5} | x3 z3-x 0  0                                        |
|                   {7} | 0  0    x3 z3-                                      |
|                   {9} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|0  0    | : -1                                                               |
|x3 z3-x |                                                                    |
|                                                                             |
|<----------------------------------------------------------------------------|
|   | 15x2-23xy+43y2+39xz-17yz-11z2 40x+11y+46z 22x2-47xy-7y2-23xz+2yz+29z2   |
|   | 48x2+36xy+11y2+35xz-38yz+33z2 -28x+y-3z   -47x2+15xy-13y2-37xz-10yz+30z2|
|                                                                             |
|  0  0    | <----------------------------------------------------------------|
|x 0  0    |    {2} | -18x2y+27xy2-9y3+39x2z-22xyz-32y2z+32xz2-20yz2      4x2y|
|  x3 z3-x |    {1} | 24x2y2-15xy3+33y4-30x2yz+39xy2z-49y3z-48x2z2-33y2z2 36x2|
|               {2} | -19x2y-20xy2+36y3+17x2z+44xyz+9y2z-39xz2-39yz2      -9x2|
|                                                                             |
|  0  0    | <----------------------------------------------------------------|
|x 0  0    |    {5} | 30x2+13xy-13y2-17xz+3yz-41z2 8x2y2-46xy3+42y4-29x2yz+49x|
|  x3 z3-x |    {7} | 8                            15x2+18xy-46y2-16xz+12yz-18|
|               {9} | 0                            27                         |
|-----------------------------------------------------------------------------|
|---- cokernel {2} | x3 z3-x 0  0    0  0    | : 0                            |
| |            {1} | 0  0    x3 z3-x 0  0    |                                |
| |            {2} | 0  0    0  0    x3 z3-x |                                |
|                                                                             |
|-----------------------------------------------------------------------------|
|3+22xy4-8y5+13x2y2z-49xy3z+43y4z-26x2yz2-11xy2z2-8y3z2   -49x2y5+30xy6-40y7-1|
|y4-30xy5-28y6-3x2y3z+41xy4z-6y5z-22x2y2z2+16xy3z2+35y4z2 -31x2y6-48xy7+30y8-3|
|y3+40xy4+25y5-35x2y2z+3xy3z-2y4z+6x2yz2-31xy2z2-41y3z2   -49x2y5+46xy6-22y7+2|
|                                                                             |
|---------------------------------- cokernel {7} | x3 z3-x 0  0    | : 2      |
|y2z+23y3z+30x2z2-18xyz2-28y2z2 |            {9} | 0  0    x3 z3-x |          |
|z2                             |                                             |
|                               |                                             |
|-----------------------------------------------------------------------------|
|----------------------------------------------- cokernel {5} | x3 z3-x 0     |
|3x2y4z-47xy5z+37y6z+4x2y3z2+27xy4z2-35y5z2  |            {7} | 0  0    x3    |
|9x2y5z-29xy6z-37y7z-31x2y4z2-48xy5z2+47y6z2 |            {9} | 0  0    0     |
|8x2y4z+xy5z+10y6z-18x2y3z2+40xy4z2+7y5z2    |                                |
|-----------------------------------------------------------------------------|
|0    0  0    | : 1                                                           |
|z3-x 0  0    |                                                               |
|0    x3 z3-x |                                                               |
+-----------------------------------------------------------------------------+
|i14 : assert not isNullHomotopic g                                           |
+-----------------------------------------------------------------------------+

This procedure also works for complex maps whose degree is non-zero.

+-----------------------------------------------------------------------------+
|i15 : f = randomComplexMap(C, C[2],                                          |
|                                                                             |
|o15 = -1 : 0 <----- cokernel | x3 z3                                         |
|                0            | 0  0                                          |
|                                                                             |
|      0 : cokernel | x3 z3-x 0  0                                            |
|                   | 0  0    x3 z3-x                                         |
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | x3 z3-x 0                                           |
|                   {1} | 0  0    x3                                          |
|                   {2} | 0  0    0                                           |
|                                                                             |
|                                                                             |
|      2 : cokernel {5} | x3 z3-x 0                                           |
|                   {7} | 0  0    x3                                          |
|                   {9} | 0  0    0                                           |
|                                                                             |
|                                                                             |
|o15 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|Boundary => true, Degree => 1)                                               |
|                                                                             |
|-x 0  0    | : -2                                                            |
|   x3 z3-x |                                                                 |
|                                                                             |
| | <-------------------------------------------------------------------- coke|
| |    | 39xy+44y2-19yz+36x      26y-37z -37x2-47xy+28y2-6yz-12z2+28x |       |
|      | 34y2+39xz-20yz-19z2+23x 23y+24z -14x2+28y2-47xz+28yz+17z2    |       |
|                                                                             |
|0    0  0    | <-------------------------------------------------------------|
|z3-x 0  0    |    {2} | -24x2y+28y3-28xz+24x                                 |
|0    x3 z3-x |    {1} | 20x2y2-47xy3+28y4+19x2yz-6y3z-14y2z2+47x2z-28xyz+6xz2|
|                  {2} | -24y3+24xz                                           |
|                                                                             |
|0    0  0    | <-------------------------------------------------------------|
|z3-x 0  0    |    {5} | 33x2+28xy+26y2-29xz+5yz-37z2 3x2y2-28xy3+30y4+9x2yz+4|
|0    x3 z3-x |    {7} | -33                          5x2-20xy-32y2-13xz+6yz-2|
|                  {9} | 0                            12                      |
|-----------------------------------------------------------------------------|
|rnel {2} | x3 z3-x 0  0    0  0    | : -1                                    |
|     {1} | 0  0    x3 z3-x 0  0    |                                         |
|     {2} | 0  0    0  0    x3 z3-x |                                         |
|                                                                             |
|-----------------------------------------------------------------------------|
|                2x2y3-5x2y2z+37x2yz2+28x2y+26xy2-29x2z+5xyz-37xz2            |
|+39x2-20xy-19xz 28x2y4-6x2y3z-14x2y2z2-28xy3z2-26y4z2+29x2y2-5xy3+37xy2z     |
|                -24x2y3+28xy4+26y5-29xy3z+5y4z-37y3z2-28x2yz-26xy2z+29x2z2-5x|
|                                                                             |
|---------------------------------- cokernel {7} | x3 z3-x 0  0    | : 1      |
|2xy2z+4y3z-2x2z2+44xyz2+22y2z2 |            {9} | 0  0    x3 z3-x |          |
|z2                             |                                             |
|                               |                                             |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
|         -30x2y5-4x2y4z-22x2y3z2-28x2y3+30xy4+42x2y2z+4xy3z+44x2yz2+22xy2z2  |
|         29x2y4z2+28xy5z2-30y6z2-42x2y4-4xy5-44x2y3z-22xy4z                  |
|yz2+37x2 -29x2y5-28xy6+30y7+15x2y4z+42xy5z+4y6z-4x2y3z2+44xy4z2+22y5z2+28x2y3|
|-----------------------------------------------------------------------------|
|----------------------------------- cokernel {5} | x3 z3-x 0  0    0  0    | |
|                                |            {7} | 0  0    x3 z3-x 0  0    | |
|                                |            {9} | 0  0    0  0    x3 z3-x | |
|z-30xy4z-42x2y2z2-4xy3z2-22x2y2 |                                            |
|-----------------------------------------------------------------------------|
|: 0                                                                          |
+-----------------------------------------------------------------------------+
|i16 : assert isNullHomotopic f                                               |
+-----------------------------------------------------------------------------+
|i17 : h = nullHomotopy f                                                     |
|                                                                             |
|o17 = 0 : cokernel | x3 z3-x 0  0    |                                       |
|                   | 0  0    x3 z3-x |                                       |
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | x3 z3-x 0  0                                        |
|                   {1} | 0  0    x3 z3-                                      |
|                   {2} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      2 : cokernel {5} | x3 z3-x 0  0                                        |
|                   {7} | 0  0    x3 z3-                                      |
|                   {9} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      3 : cokernel {7} | x3 z3-x 0  0                                        |
|                   {9} | 0  0    x3 z3-                                      |
|                                                                             |
|                                                                             |
|o17 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|<-------------------------------------- cokernel | x3 z3-x 0  0    | : -2    |
|   | -47yz+26        47y2-37        |            | 0  0    x3 z3-x |         |
|   | -24x2yz-47z2+23 24x2y2+47yz+24 |                                        |
|                                                                             |
|  0  0    | <------------------------------------------------ cokernel {2} | |
|x 0  0    |    {2} | 24x2y2-10             0 -28          |            {1} | |
|  x3 z3-x |    {1} | 47y3-47xz-39x+20y+19z 0 47x2y-28y+6z |            {2} | |
|               {2} | 0                     0 38           |                  |
|                                                                             |
|  0  0    | <----------------------------------------------------------------|
|x 0  0    |    {5} | 14 14x2+28xy+26y2-29xz+5yz-37z2 -29x2y2-28xy3+30y4+15x2y|
|  x3 z3-x |    {7} | 0  0                            0                       |
|               {9} | 0  0                            12                      |
|                                                                             |
|  | <------------------------------------------ cokernel {7} | x3 z3-x 0  0  |
|x |    {7} | 33 -5x2+20xy+32y2+13xz-6yz+2z2 |            {9} | 0  0    x3 z3-|
|       {9} | 0  0                           |                                |
|-----------------------------------------------------------------------------|
|x3 z3-x 0  0    0  0    | : -1                                               |
|0  0    x3 z3-x 0  0    |                                                    |
|0  0    0  0    x3 z3-x |                                                    |
|                                                                             |
|                                                                             |
|------------------------------------- cokernel {5} | x3 z3-x 0  0    0  0    |
|z+42xy2z+4y3z-4x2z2+44xyz2+22y2z2 |            {7} | 0  0    x3 z3-x 0  0    |
|                                  |            {9} | 0  0    0  0    x3 z3-x |
|                                  |                                          |
|                                                                             |
|  | : 1                                                                      |
|x |                                                                          |
|-----------------------------------------------------------------------------|
|| : 0                                                                        |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i18 : assert isNullHomotopyOf(h, f)                                          |
+-----------------------------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * isNullHomotopyOf(ComplexMap,ComplexMap)
    -- whether the first map of
    chain complexes is a null homotopy for the second
  * nullHomotopy(ComplexMap) -- a map
    which is a candidate for being a null homotopy
  * randomComplexMap -- a
    random map of chain complexes
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes

Ways to use this method:
========================

  * isNullHomotopic(ComplexMap), --
    whether a map of complexes is null-homotopic

isNullHomotopyOf(ComplexMap,ComplexMap) -- whether the first map of chain complexes is a null homotopy for the second
*********************************************************************************************************************

Synopsis
========

  * Function: isNullHomotopyOf,
  * Usage:
        isNullHomotopyOf(h, f)
  * Inputs:
      * h, a map of complexes,
      * f, a map of complexes,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when $h$ is
        a null homotopy of $f$

Description
===========

A map of chain complexes $f \colon C \to D$ is null-homotopic if there exists a
map of chain complexes $h : C \to D$ of degree $\deg(f)+1$, such that we have
the equality \[ f = \operatorname{dd}^D h + (-1)^{\deg(f)} h
\operatorname{dd}^C. \]

As a first example, we construct a map of chain complexes in which the null
homotopy is given by the identity.

+-------------------------------------------------------------------+
|i1 : R = ZZ/101[x,y,z];                                            |
+-------------------------------------------------------------------+
|i2 : M = cokernel matrix{{x,y,z^2}, {y^2,z,x^2}}                   |
|                                                                   |
|o2 = cokernel | x  y z2 |                                          |
|              | y2 z x2 |                                          |
|                                                                   |
|                            2                                      |
|o2 : R-module, quotient of R                                       |
+-------------------------------------------------------------------+
|i3 : C = complex {id_M}                                            |
|                                                                   |
|o3 = cokernel | x  y z2 | <-- cokernel | x  y z2 |                 |
|              | y2 z x2 |              | y2 z x2 |                 |
|                                                                   |
|     0                        1                                    |
|                                                                   |
|o3 : Complex                                                       |
+-------------------------------------------------------------------+
|i4 : h = map(C, C, i -> if i == 0 then id_M, Degree => 1)          |
|                                                                   |
|o4 = 1 : cokernel | x  y z2 | <----------- cokernel | x  y z2 | : 0|
|                  | y2 z x2 |    | 1 0 |            | y2 z x2 |    |
|                                 | 0 1 |                           |
|                                                                   |
|o4 : ComplexMap                                                    |
+-------------------------------------------------------------------+
|i5 : isWellDefined h                                               |
|                                                                   |
|o5 = true                                                          |
+-------------------------------------------------------------------+
|i6 : assert isNullHomotopyOf(h, id_C)                              |
+-------------------------------------------------------------------+
|i7 : assert isNullHomotopic id_C                                   |
+-------------------------------------------------------------------+

A random map of chain complexes, arising as a boundary in the associated Hom
complex, is automatically null homotopic.  We use the method
nullHomotopy, to construct a witness and verify
it is a null homotopy.

+-----------------------------------------------------------------------------+
|i8 : C = (freeResolution M) ** R^1/ideal(x^3, z^3-x)                         |
|                                                                             |
|o8 = cokernel | x3 z3-x 0  0    | <-- cokernel {2} | x3 z3-x 0  0    0  0    |
|              | 0  0    x3 z3-x |              {1} | 0  0    x3 z3-x 0  0    |
|                                               {2} | 0  0    0  0    x3 z3-x |
|     0                                                                       |
|                                      1                                      |
|                                                                             |
|o8 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|| <-- cokernel {5} | x3 z3-x 0  0    0  0    | <-- cokernel {7} | x3 z3-x 0  |
||              {7} | 0  0    x3 z3-x 0  0    |              {9} | 0  0    x3 |
||              {9} | 0  0    0  0    x3 z3-x |                               |
|                                                   3                         |
|      2                                                                      |
|-----------------------------------------------------------------------------|
|0    |                                                                       |
|z3-x |                                                                       |
+-----------------------------------------------------------------------------+
|i9 : f = randomComplexMap(C, C[1],                                           |
|                                                                             |
|o9 = -1 : 0 <----- cokernel | x3 z3                                          |
|               0            | 0  0                                           |
|                                                                             |
|     0 : cokernel | x3 z3-x 0  0                                             |
|                  | 0  0    x3 z3-x                                          |
|                                                                             |
|                                                                             |
|     1 : cokernel {2} | x3 z3-x 0                                            |
|                  {1} | 0  0    x3                                           |
|                  {2} | 0  0    0                                            |
|                                                                             |
|                                                                             |
|     2 : cokernel {5} | x3 z3-x 0                                            |
|                  {7} | 0  0    x3                                           |
|                  {9} | 0  0    0                                            |
|                                                                             |
|                                                                             |
|o9 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|Boundary => true)                                                            |
|                                                                             |
|-x 0  0    | : -1                                                            |
|   x3 z3-x |                                                                 |
|                                                                             |
| | <-------------------------------------------------------------------------|
| |    | 19xy+20y2-29yz-8z2-5x        -46y+30z 30x2-24xy-38y2-16yz+15z2-29x | |
|      | -8x2+48y2+19xz-10yz-29z2+36x 36y+7z   -33x2-29y2-24xz-38yz+20z2    | |
|                                                                             |
|0    0  0    | <-------------------------------------------------------------|
|z3-x 0  0    |    {2} | 2x2y-29y3+29xz-2x                                    |
|0    x3 z3-x |    {1} | 10x2y2-24xy3-38y4+29x2yz-16y3z+43y2z2+24x2z+38xyz+16x|
|                  {2} | 8x2y+18y3-18xz-8x                                    |
|                                                                             |
|0    0  0    | <-------------------------------------------------------------|
|z3-x 0  0    |    {5} | 21x2-34xy+47y2-19xz+39yz+18z2 -19x2y2+43xy3+47y4+16x2|
|0    x3 z3-x |    {7} | 13                            -16x2-22xy-48y2-45xz+32|
|                  {9} | 0                             -47                    |
|-----------------------------------------------------------------------------|
|- cokernel {2} | x3 z3-x 0  0    0  0    | : 0                               |
|           {1} | 0  0    x3 z3-x 0  0    |                                   |
|           {2} | 0  0    0  0    x3 z3-x |                                   |
|                                                                             |
|-----------------------------------------------------------------------------|
|                  25x2y3-39x2y2z-18x2yz2-34x2y+47xy2-19x2z+39xyz+18xz2       |
|z2+19x2-10xy-29xz -38x2y4-16x2y3z+9x2y2z2+34xy3z2-47y4z2+19x2y2-39xy3-18xy2z |
|                  -49x2y3-34xy4+47y5-19xy3z+39y4z+18y3z2+34x2yz-47xy2z+19x2z2|
|                                                                             |
|-------------------------------------- cokernel {7} | x3 z3-x 0  0    | : 2  |
|yz+15xy2z-38y3z-7x2z2+28xyz2-2y2z2 |            {9} | 0  0    x3 z3-x |      |
|yz-47z2                            |                                         |
|                                   |                                         |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
|             -47x2y5+38x2y4z+2x2y3z2+43x2y3+47xy4+15x2y2z-38xy3z+28x2yz2-2xy2|
|             -34x2y4z2-43xy5z2-47y6z2-15x2y4+38xy5-28x2y3z+2xy4z             |
|-39xyz2-18x2 34x2y5+43xy6+47y7+48x2y4z+15xy5z-38y6z+47x2y3z2+28xy4z2-2y5z2-43|
|-----------------------------------------------------------------------------|
|--------------------------------------- cokernel {5} | x3 z3-x 0  0    0     |
|z2                                  |            {7} | 0  0    x3 z3-x 0     |
|                                    |            {9} | 0  0    0  0    x3    |
|x2y3z-47xy4z-15x2y2z2+38xy3z2+2x2y2 |                                        |
|-----------------------------------------------------------------------------|
|0    | : 1                                                                   |
|0    |                                                                       |
|z3-x |                                                                       |
+-----------------------------------------------------------------------------+
|i10 : assert isNullHomotopic f                                               |
+-----------------------------------------------------------------------------+
|i11 : h = nullHomotopy f                                                     |
|                                                                             |
|o11 = 0 : cokernel | x3 z3-x 0  0    |                                       |
|                   | 0  0    x3 z3-x |                                       |
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | x3 z3-x 0  0                                        |
|                   {1} | 0  0    x3 z3-                                      |
|                   {2} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      2 : cokernel {5} | x3 z3-x 0  0                                        |
|                   {7} | 0  0    x3 z3-                                      |
|                   {9} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      3 : cokernel {7} | x3 z3-x 0  0                                        |
|                   {9} | 0  0    x3 z3-                                      |
|                                                                             |
|                                                                             |
|o11 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|<----------------------------------- cokernel | x3 z3-x 0  0    | : -1       |
|   | 24yz+46        -24y2-30     |            | 0  0    x3 z3-x |            |
|   | -2x2yz+24z2-36 2x2y2-24yz-7 |                                           |
|                                                                             |
|  0  0    | <--------------------------------------------------- cokernel {2}|
|x 0  0    |    {2} | 2x2y2+41               0 -29            |            {1}|
|  x3 z3-x |    {1} | -24y3+24xz+19x-10y-29z 0 -24x2y-38y-16z |            {2}|
|               {2} | -8                     0 -40            |               |
|                                                                             |
|  0  0    | <----------------------------------------------------------------|
|x 0  0    |    {5} | 43 9x2+34xy-47y2+19xz-39yz-18z2 -34x2y2-43xy3-47y4-48x2y|
|  x3 z3-x |    {7} | 0  0                            0                       |
|               {9} | 0  0                            47                      |
|                                                                             |
|  | <--------------------------------------------- cokernel {7} | x3 z3-x 0  |
|x |    {7} | 13 -16x2-22xy-48y2-45xz+32yz-47z2 |            {9} | 0  0    x3 |
|       {9} | 0  0                              |                             |
|-----------------------------------------------------------------------------|
| | x3 z3-x 0  0    0  0    | : 0                                             |
| | 0  0    x3 z3-x 0  0    |                                                 |
| | 0  0    0  0    x3 z3-x |                                                 |
|                                                                             |
|                                                                             |
|-------------------------------------- cokernel {5} | x3 z3-x 0  0    0  0   |
|z-15xy2z+38y3z-47x2z2-28xyz2+2y2z2 |            {7} | 0  0    x3 z3-x 0  0   |
|                                   |            {9} | 0  0    0  0    x3 z3-x|
|                                   |                                         |
|                                                                             |
|0    | : 2                                                                   |
|z3-x |                                                                       |
|-----------------------------------------------------------------------------|
|| : 1                                                                        |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i12 : assert isNullHomotopyOf(h, f)                                          |
+-----------------------------------------------------------------------------+

By assigning debugLevel (Macaulay2Doc), a positive value, this
method provides some information about the nature of the failure to be a null
homotopy.

+-----------------------------------------------------------------------------+
|i13 : g1 = randomComplexMap(C, C[1],                                         |
|                                                                             |
|o13 = 0 : cokernel | x3 z3-x 0  0                                            |
|                   | 0  0    x3 z3-x                                         |
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | x3 z3-x 0                                           |
|                   {1} | 0  0    x3                                          |
|                   {2} | 0  0    0                                           |
|                                                                             |
|                                                                             |
|      2 : cokernel {5} | x3 z3-x 0                                           |
|                   {7} | 0  0    x3                                          |
|                   {9} | 0  0    0                                           |
|                                                                             |
|                                                                             |
|      3 : cokernel {7} | x3 z3-x 0                                           |
|                   {9} | 0  0    x3                                          |
|                                                                             |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
| Degree => 1)                                                                |
|                                                                             |
| | <-------------- cokernel | x3 z3-x 0  0    | : -1                         |
| |    | 15  39 |            | 0  0    x3 z3-x |                              |
|      | -23 43 |                                                             |
|                                                                             |
|0    0  0    | <--------------------------------------- cokernel {2} | x3 z3-|
|z3-x 0  0    |    {2} | -17          0  -38         |            {1} | 0  0  |
|0    x3 z3-x |    {1} | -11x+48y+36z 11 33x+40y+11z |            {2} | 0  0  |
|                  {2} | 35           0  46          |                        |
|                                                                             |
|0    0  0    | <-------------------------------------------------------------|
|z3-x 0  0    |    {5} | -28 x2-3xy-47y2+22xz-23yz-7z2 29x2y2-37xy3+30y4-47x2y|
|0    x3 z3-x |    {7} | 0   2                         27x2-22xy-9y2+32xz-32yz|
|                  {9} | 0   0                         24                     |
|                                                                             |
|0    | <----------------------------------------- cokernel {7} | x3 z3-x 0  0|
|z3-x |    {7} | -30 -48x2-15xy+39xz+33yz-49z2 |            {9} | 0  0    x3 z|
|          {9} | 0   -33                       |                              |
|-----------------------------------------------------------------------------|
|x 0  0    0  0    | : 0                                                      |
|  x3 z3-x 0  0    |                                                          |
|  0  0    x3 z3-x |                                                          |
|                                                                             |
|                                                                             |
|--------------------------------------- cokernel {5} | x3 z3-x 0  0    0     |
|z-13xy2z-18y3z+15x2z2-10xyz2+39y2z2 |            {7} | 0  0    x3 z3-x 0     |
|-20z2                               |            {9} | 0  0    0  0    x3    |
|                                    |                                        |
|                                                                             |
|    | : 2                                                                    |
|3-x |                                                                        |
|-----------------------------------------------------------------------------|
|0    | : 1                                                                   |
|0    |                                                                       |
|z3-x |                                                                       |
+-----------------------------------------------------------------------------+
|i14 : g2 = randomComplexMap(C,                                               |
|                                                                             |
|o14 = -2 : 0 <----- cokernel |                                               |
|                0            |                                               |
|                                                                             |
|      -1 : 0 <----- cokernel {2                                              |
|                0            {1                                              |
|                             {2                                              |
|                                                                             |
|      0 : cokernel | x3 z3-x 0                                               |
|                   | 0  0    x3                                              |
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | x3 z3-                                              |
|                   {1} | 0  0                                                |
|                   {2} | 0  0                                                |
|                                                                             |
|                                                                             |
|o14 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|C[1], Degree => -1)                                                          |
|                                                                             |
|x3 z3-x 0  0    | : -1                                                       |
|0  0    x3 z3-x |                                                            |
|                                                                             |
|} | x3 z3-x 0  0    0  0    | : 0                                            |
|} | 0  0    x3 z3-x 0  0    |                                                |
|} | 0  0    0  0    x3 z3-x |                                                |
|                                                                             |
| 0    | <--------------------------------------------------------------------|
| z3-x |    | -19x2y3+44xy4+9y5+17x2y2z-39xy3z-39y4z-20x2yz2+36xy2z2+4y3z2 -3x|
|           | 13x2y3-49xy4+43y5-26x2y2z-11xy3z-8y4z+22x2yz2-8xy2z2+36y3z2  -35|
|                                                                             |
|x 0  0    0  0    | <--------------------------------------------------------|
|  x3 z3-x 0  0    |    {2} | 28x2y3+xy4+10y5-18x2y2z+40xy3z+7y4z+46x2yz2-22xy|
|  0  0    x3 z3-x |    {1} | 13x2y4+3xy5+8y6-17x2y3z-41xy4z-29y5z-13x2y2z2+8x|
|                       {2} | -46x2y3+42xy4+15y5+49x2y2z+23xy3z+18y4z-18x2yz2-|
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
|2y5+41xy6-6y7-22x2y4z+16xy5z+35y6z-30x2y3z2-28xy4z2-9y5z2 -13x2y7-47xy8+37y9+|
|x2y5+3xy6-2y7+6x2y4z-31xy5z-41y6z+40x2y3z2+25xy4z2-49y5z2 -39x2y7-29xy8-37y9-|
|                                                                             |
|-----------------------------------------------------------------------------|
|2z2+30y3z2     -46x2y5+27xy6-37y7+12x2y4z-21xy5z-23y6z-18x2y3z2+23xy4z2+44y5z|
|y3z2+30y4z2    -39x2y6+47y8+20x2y5z-47xy6z-28y7z+19x2y4z2-28xy5z2+6y6z2      |
|28xy2z2-16y3z2 -9x2y5-29xy6-37y7-33x2y4z+26xy5z-33y6z+28x2y3z2+5xy4z2-28y5z2 |
|-----------------------------------------------------------------------------|
|------------------------------------------------ cokernel {5} | x3 z3-x 0    |
|4x2y6z+27xy7z-35y8z+30x2y5z2-40xy6z2-31y7z2  |            {7} | 0  0    x3   |
|31x2y6z-48xy7z+47y8z-48x2y5z2+30xy6z2-49y7z2 |            {9} | 0  0    0    |
|                                                                             |
|----- cokernel {7} | x3 z3-x 0  0    | : 2                                   |
|2 |            {9} | 0  0    x3 z3-x |                                       |
|  |                                                                          |
|  |                                                                          |
|-----------------------------------------------------------------------------|
|0    0  0    | : 1                                                           |
|z3-x 0  0    |                                                               |
|0    x3 z3-x |                                                               |
+-----------------------------------------------------------------------------+
|i15 : debugLevel = 1                                                         |
|                                                                             |
|o15 = 1                                                                      |
+-----------------------------------------------------------------------------+
|i16 : assert not isNullHomotopyOf(g1, f)                                     |
| -- 1 : (ReduceHooks) with Strategy => Default from                          |
| -- 1 : (ReduceHooks) with Strategy => Default from                          |
| -- 1 : (ReduceHooks) with Strategy => Default from                          |
| -- 1 : (ReduceHooks) with Strategy => Default from                          |
| -- 1 : (ReduceHooks) with Strategy => Default from                          |
| -- 1 : (ReduceHooks) with Strategy => Default from                          |
| -- 1 : (ReduceHooks) with Strategy => Default from                          |
| -- 1 : (ReduceHooks) with Strategy => Default from                          |
| -- 1 : (ReduceHooks) with Strategy => Default from                          |
|fails to be a null homotopy at location 0                                    |
|fails to be a null homotopy at location 1                                    |
|fails to be a null homotopy at location 2                                    |
|-----------------------------------------------------------------------------|
|-*Function[/usr/share/Macaulay2/Core/matrix.m2:76:55-76:85]*-                |
|-*Function[/usr/share/Macaulay2/Core/matrix.m2:76:55-76:85]*-                |
|-*Function[/usr/share/Macaulay2/Core/matrix.m2:76:55-76:85]*-                |
|-*Function[/usr/share/Macaulay2/Core/matrix.m2:76:55-76:85]*-                |
|-*Function[/usr/share/Macaulay2/Core/matrix.m2:76:55-76:85]*-                |
|-*Function[/usr/share/Macaulay2/Core/matrix.m2:76:55-76:85]*-                |
|-*Function[/usr/share/Macaulay2/Core/matrix.m2:76:55-76:85]*-                |
|-*Function[/usr/share/Macaulay2/Core/matrix.m2:76:55-76:85]*-                |
|-*Function[/usr/share/Macaulay2/Core/matrix.m2:76:55-76:85]*-                |
+-----------------------------------------------------------------------------+
|i17 : assert not isNullHomotopyOf(g2, f)                                     |
|expected degree of first map to be one more than degree of the second        |
+-----------------------------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * isNullHomotopic(ComplexMap), --
    whether a map of complexes is null-homotopic
  * nullHomotopy(ComplexMap) -- a map
    which is a candidate for being a null homotopy
  * randomComplexMap -- a
    random map of chain complexes
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes

Ways to use this method:
========================

  * isNullHomotopyOf(ComplexMap,ComplexMap)
    -- whether the first map of
    chain complexes is a null homotopy for the second

isQuasiIsomorphism(ComplexMap) -- whether a map of complexes is a quasi-isomorphism
***********************************************************************************

Synopsis
========

  * Function: isQuasiIsomorphism,
  * Usage:
        isQuasiIsomorphism f
  * Inputs:
      * f, a map of complexes,
  * Optional inputs (Macaulay2Doc),:
      * Concentration => a sequence (Macaulay2Doc), default
        value (-infinity,infinity), restricts attention to the induced maps
        indexed by elements in the given interval
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when $f$ is
        a morphism of complexes such that the induced maps on homology are all
        isomorphisms

Description
===========

The cone, of a map $f \colon C \to D$ is acyclic
exactly when $f$ is a quasi-isomorphism.

+---------------------------------------------+
|i1 : S = ZZ/32003[x,y,z];                    |
+---------------------------------------------+
|i2 : C = freeResolution coker vars S         |
|                                             |
|      1      3      3      1                 |
|o2 = S  <-- S  <-- S  <-- S                  |
|                                             |
|     0      1      2      3                  |
|                                             |
|o2 : Complex                                 |
+---------------------------------------------+
|i3 : f = augmentationMap C                   |
|                                             |
|                                        1    |
|o3 = 0 : cokernel | x y z | <--------- S  : 0|
|                               | 1 |         |
|                                             |
|o3 : ComplexMap                              |
+---------------------------------------------+
|i4 : assert isQuasiIsomorphism f             |
+---------------------------------------------+
|i5 : assert(0 == prune HH cone f)            |
+---------------------------------------------+
|i6 : assert isIsomorphism HH_0 f             |
+---------------------------------------------+
|i7 : assert isIsomorphism HH_1 f             |
+---------------------------------------------+

XXX TODO. Free resolutions of complexes produce quasi isomorphisms. (use
example to doc of (resolution, Complex)).

+-----------------------------------------------------------------------------+
|i8 : D = complex{random(S^2, S^{-3,-3,-4})}                                  |
|                                                                             |
|      2      3                                                               |
|o8 = S  <-- S                                                                |
|                                                                             |
|     0      1                                                                |
|                                                                             |
|o8 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i9 : prune HH D                                                              |
|                                                                             |
|                                                                             |
|o9 = cokernel | x3-2709x2y-7293xy2+10856y3+3980x2z-11102xyz+7611y2z-4512xz2-2|
|              | 2794x2y+8580xy2+3768y3-10164x2z+12325xyz+3393y2z-3650xz2-6859|
|                                                                             |
|     0                                                                       |
|                                                                             |
|o9 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|                                                                             |
|645yz2+11682z3 15989x2y+6239xy2-5484y3-3269x2z-11632xyz+8838y2z+5916xz2+4223y|
|yz2+7446z3     x3+13290x2y-12034xy2-2305y3+1291x2z-7317xyz-8020y2z-749xz2-888|
|                                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|z2+2704z3   10021x2y2+5151xy3-12405y4-10408x2yz+15788xy2z-6266y3z-10577x2z2-9|
|4yz2+8664z3 x2y2-14582xy3+13590y4-5127x2yz+14886xy2z+4549y3z-7332x2z2-3153xyz|
|                                                                             |
|-----------------------------------------------------------------------------|
|                                                  1                          |
|208xyz2-5782y2z2+10728xz3+13597yz3-11490z4 | <-- S                           |
|2-15321y2z2+1454xz3-6214yz3-3074z4         |                                 |
|                                                 1                           |
+-----------------------------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * cone(ComplexMap) -- make the mapping cone of a
    morphism of chain complexes
  * liftMapAlongQuasiIsomorphism
    -- lift a map of
    chain complexes along a quasi-isomorphism

Ways to use this method:
========================

  * isQuasiIsomorphism(ComplexMap),
    -- whether a map of complexes is a quasi-isomorphism

isShortExactSequence(Complex) -- whether a chain complex is a short exact sequence
**********************************************************************************

Synopsis
========

  * Function: isShortExactSequence,
  * Usage:
        isShortExactSequence C
  * Inputs:
      * C, a complex,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true (Macaulay2Doc),
        if $C$ is a short exact sequence

Description
===========

A short exact sequence of modules is a complex \[ 0 \to L \xrightarrow{f} M
\xrightarrow{g} N \to 0\] consisting of two homomorphisms of modules $f \colon
L \to M$ and $g \colon M \to N$ such that $g f = 0$, $\operatorname{image} f =
\operatorname{ker} g$, $\operatorname{ker} f = 0$, and $\operatorname{coker} g
= 0$.

From a homomorphism $h \colon M \to N$, one obtains a short exact sequence \[ 0
\to \operatorname{image} h \to N \to \operatorname{coker} h \to 0. \]

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c];                                                      |
+-----------------------------------------------------------------------------+
|i2 : h = random(R^3, R^{4:-1})                                               |
|                                                                             |
|o2 = | 24a-36b-30c  -22a-29b-24c -47a-39b-18c 2a+16b+22c   |                 |
|     | -29a+19b+19c -38a-16b+39c -13a-43b-15c 45a-34b-48c  |                 |
|     | -10a-29b-8c  21a+34b+19c  -28a-47b+38c -47a+47b+19c |                 |
|                                                                             |
|             3       4                                                       |
|o2 : Matrix R  <--- R                                                        |
+-----------------------------------------------------------------------------+
|i3 : f = inducedMap(target h, image h)                                       |
|                                                                             |
|o3 = | 24a-36b-30c  -22a-29b-24c -47a-39b-18c 2a+16b+22c   |                 |
|     | -29a+19b+19c -38a-16b+39c -13a-43b-15c 45a-34b-48c  |                 |
|     | -10a-29b-8c  21a+34b+19c  -28a-47b+38c -47a+47b+19c |                 |
|                                                                             |
|o3 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i4 : g = inducedMap(cokernel h, target h)                                    |
|                                                                             |
|o4 = | 1 0 0 |                                                               |
|     | 0 1 0 |                                                               |
|     | 0 0 1 |                                                               |
|                                                                             |
|o4 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i5 : C = complex {g, f}                                                      |
|                                                                             |
|                                                                           3 |
|o5 = cokernel | 24a-36b-30c  -22a-29b-24c -47a-39b-18c 2a+16b+22c   | <-- R  |
|              | -29a+19b+19c -38a-16b+39c -13a-43b-15c 45a-34b-48c  |        |
|              | -10a-29b-8c  21a+34b+19c  -28a-47b+38c -47a+47b+19c |     1  |
|                                                                             |
|     0                                                                       |
|                                                                             |
|o5 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|<-- image | 24a-36b-30c  -22a-29b-24c -47a-39b-18c 2a+16b+22c   |            |
|          | -29a+19b+19c -38a-16b+39c -13a-43b-15c 45a-34b-48c  |            |
|          | -10a-29b-8c  21a+34b+19c  -28a-47b+38c -47a+47b+19c |            |
|                                                                             |
|    2                                                                        |
+-----------------------------------------------------------------------------+
|i6 : isWellDefined C                                                         |
|                                                                             |
|o6 = true                                                                    |
+-----------------------------------------------------------------------------+
|i7 : assert isShortExactSequence C                                           |
+-----------------------------------------------------------------------------+
|i8 : assert isShortExactSequence(C[10])                                      |
+-----------------------------------------------------------------------------+
|i9 : assert not isShortExactSequence(C ++ C[6])                              |
+-----------------------------------------------------------------------------+
|i10 : D = complex(R^1, Base=>4) ++ complex(R^1, Base=>2)                     |
|                                                                             |
|       1            1                                                        |
|o10 = R  <-- 0 <-- R                                                         |
|                                                                             |
|      2      3     4                                                         |
|                                                                             |
|o10 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i11 : assert not isShortExactSequence D                                      |
+-----------------------------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * isShortExactSequence(Matrix,Matrix)
    -- whether a pair of matrices
    forms a short exact sequence
  * isShortExactSequence(ComplexMap,ComplexMap)
    -- whether a pair of
    complex maps forms a short exact sequence

Ways to use this method:
========================

  * isShortExactSequence(Complex), --
    whether a chain complex is a short exact sequence

isShortExactSequence(ComplexMap,ComplexMap) -- whether a pair of complex maps forms a short exact sequence
**********************************************************************************************************

Synopsis
========

  * Function: isShortExactSequence,
  * Usage:
        isShortExactSequence(g, f)
  * Inputs:
      * f, a map of complexes,
      * g, a map of complexes,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true (Macaulay2Doc),
        if these form a short exact sequence

Description
===========

A short exact sequence of complexes \[ 0 \to B \xrightarrow{f} C
\xrightarrow{g} D \to 0\] consists of two morphisms of complexes $f \colon B
\to C$ and $g \colon C \to D$ such that $g f = 0$, $\operatorname{image} f =
\operatorname{ker} g$, $\operatorname{ker} f = 0$, and $\operatorname{coker} g
= 0$.

From a complex morphism $h \colon B \to C$, one obtains a short exact sequence
\[ 0 \to \operatorname{image} h \to C \to \operatorname{coker} h \to 0. \]

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c];                                                      |
+-----------------------------------------------------------------------------+
|i2 : B = freeResolution coker matrix{{a^2*b, a*b*c, c^3}}                    |
|                                                                             |
|      1      3      2                                                        |
|o2 = R  <-- R  <-- R                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : C = freeResolution coker vars R                                         |
|                                                                             |
|      1      3      3      1                                                 |
|o3 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : h = randomComplexMap(C, B, Cycle => true)                               |
|                                                                             |
|          1               1                                                  |
|o4 = 0 : R  <----------- R  : 0                                              |
|               | -47 |                                                       |
|                                                                             |
|          3                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {1} | 35ab+10b2+8ac-50bc+29c2  34ab+19b2-43ac+39bc-28c2 39ab+1|
|               {1} | 19a2-10ab-29ac+24bc+38c2 -34a2-19ab-9ac-34bc-48c2 -39a2-|
|               {1} | -8a2-22ab-24b2-29ac-38bc 43a2+24ab+34b2+28ac+48bc 2a2+16|
|                                                                             |
|          3                                                                  |
|     2 : R  <----------------------------------------------------------------|
|               {2} | -34a2-19ab-44ac+15bc+2c2     -39a2b-18ab2+24a2c-49abc+18|
|               {2} | 43a2+40ab-5b2+36ac+49bc+29c2 -22a2b-49ab2-18b3-49abc+19b|
|               {2} | -16a2+39ab+21ac+24bc+38c2    24a3-36a2b-29ab2-30a2c+19ab|
|                                                                             |
|o4 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                            3                                                |
|-------------------------- R  : 1                                            |
|8b2-2ac-3bc-22c2       |                                                     |
|18ab-13ac+47bc-38c2    |                                                     |
|ab-47b2+22ac+38bc-47c2 |                                                     |
|                                                                             |
|                         2                                                   |
|----------------------- R  : 2                                               |
|b2c+4ac2-47c3       |                                                        |
|2c-43ac2-15bc2-28c3 |                                                        |
|c+45ac2-34bc2-48c3  |                                                        |
+-----------------------------------------------------------------------------+
|i5 : f = canonicalMap(C, image h)                                            |
|                                                                             |
|          1                                                                  |
|o5 = 0 : R  <----------- image | -47 | : 0                                   |
|               | -47 |                                                       |
|                                                                             |
|          3                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               {1} | 35ab+10b2+8ac-50bc+29c2  34ab+19b2-43ac+39bc-28c2 39ab+1|
|               {1} | 19a2-10ab-29ac+24bc+38c2 -34a2-19ab-9ac-34bc-48c2 -39a2-|
|               {1} | -8a2-22ab-24b2-29ac-38bc 43a2+24ab+34b2+28ac+48bc 2a2+16|
|                                                                             |
|          3                                                                  |
|     2 : R  <----------------------------------------------------------------|
|               {2} | -34a2-19ab-44ac+15bc+2c2     -39a2b-18ab2+24a2c-49abc+18|
|               {2} | 43a2+40ab-5b2+36ac+49bc+29c2 -22a2b-49ab2-18b3-49abc+19b|
|               {2} | -16a2+39ab+21ac+24bc+38c2    24a3-36a2b-29ab2-30a2c+19ab|
|                                                                             |
|          1                                                                  |
|     3 : R  <----- image 0 : 3                                               |
|               0                                                             |
|                                                                             |
|o5 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|-------------------------- image {1} | 35ab+10b2+8ac-50bc+29c2               |
|8b2-2ac-3bc-22c2       |         {1} | 19a2-10ab-29ac+24bc+38c2              |
|18ab-13ac+47bc-38c2    |         {1} | -8a2-22ab-24b2-29ac-38bc              |
|ab-47b2+22ac+38bc-47c2 |                                                     |
|                                                                             |
|                                                                             |
|----------------------- image {2} | -34a2-19ab-44ac+15bc+2c2                 |
|b2c+4ac2-47c3       |         {2} | 43a2+40ab-5b2+36ac+49bc+29c2             |
|2c-43ac2-15bc2-28c3 |         {2} | -16a2+39ab+21ac+24bc+38c2                |
|c+45ac2-34bc2-48c3  |                                                        |
|-----------------------------------------------------------------------------|
|34ab+19b2-43ac+39bc-28c2 39ab+18b2-2ac-3bc-22c2       | : 1                  |
|-34a2-19ab-9ac-34bc-48c2 -39a2-18ab-13ac+47bc-38c2    |                      |
|43a2+24ab+34b2+28ac+48bc 2a2+16ab-47b2+22ac+38bc-47c2 |                      |
|                                                                             |
|                                                                             |
|                                                                             |
| -39a2b-18ab2+24a2c-49abc+18b2c+4ac2-47c3       | : 2                        |
| -22a2b-49ab2-18b3-49abc+19b2c-43ac2-15bc2-28c3 |                            |
| 24a3-36a2b-29ab2-30a2c+19abc+45ac2-34bc2-48c3  |                            |
+-----------------------------------------------------------------------------+
|i6 : g = canonicalMap(coker h, C)                                            |
|                                                                             |
|                                                                             |
|o6 = 0 : cokernel | -47 | <----- R                                           |
|                             0                                               |
|                                                                             |
|                                                                             |
|     1 : cokernel {1} | 35ab+10b2+                                           |
|                  {1} | 19a2-10ab-                                           |
|                  {1} | -8a2-22ab-                                           |
|                                                                             |
|                                                                             |
|                                                                             |
|     2 : cokernel {2} | -34a2-19ab                                           |
|                  {2} | 43a2+40ab-                                           |
|                  {2} | -16a2+39ab                                           |
|                                                                             |
|                                                                             |
|          1                 1                                                |
|     3 : R  <------------- R  : 3                                            |
|               {3} | 1 |                                                     |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|1                                                                            |
|  : 0                                                                        |
|                                                                             |
|                                                                             |
|                                                                             |
|8ac-50bc+29c2  34ab+19b2-43ac+39bc-28c2 39ab+18b2-2ac-3bc-22c2               |
|29ac+24bc+38c2 -34a2-19ab-9ac-34bc-48c2 -39a2-18ab-13ac+47bc-38c2            |
|24b2-29ac-38bc 43a2+24ab+34b2+28ac+48bc 2a2+16ab-47b2+22ac+38bc-47c2         |
|                                                                             |
|                                                                             |
|                                                                             |
|-44ac+15bc+2c2     -39a2b-18ab2+24a2c-49abc+18b2c+4ac2-47c3       |          |
|5b2+36ac+49bc+29c2 -22a2b-49ab2-18b3-49abc+19b2c-43ac2-15bc2-28c3 |          |
|+21ac+24bc+38c2    24a3-36a2b-29ab2-30a2c+19abc+45ac2-34bc2-48c3  |          |
|                                                                             |
|-----------------------------------------------------------------------------|
|                       3                                                     |
| | <----------------- R  : 1                                                 |
| |    {1} | 1 0 0 |                                                          |
| |    {1} | 0 1 0 |                                                          |
|      {1} | 0 0 1 |                                                          |
|                                                                             |
|                    3                                                        |
|<----------------- R  : 2                                                    |
|   {2} | 1 0 0 |                                                             |
|   {2} | 0 1 0 |                                                             |
|   {2} | 0 0 1 |                                                             |
+-----------------------------------------------------------------------------+
|i7 : assert isShortExactSequence(g,f)                                        |
+-----------------------------------------------------------------------------+

A short exact sequence of modules gives rise to a short exact sequence of
complexes.  These complexes arise as free resolutions of the modules.

+-----------------------------------------------------------------------------+
|i8 : I = ideal(a^3, b^3, c^3)                                                |
|                                                                             |
|             3   3   3                                                       |
|o8 = ideal (a , b , c )                                                      |
|                                                                             |
|o8 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i9 : J = I + ideal(a*b*c)                                                    |
|                                                                             |
|             3   3   3                                                       |
|o9 = ideal (a , b , c , a*b*c)                                               |
|                                                                             |
|o9 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i10 : K = I : ideal(a*b*c)                                                   |
|                                                                             |
|              2   2   2                                                      |
|o10 = ideal (c , b , a )                                                     |
|                                                                             |
|o10 : Ideal of R                                                             |
+-----------------------------------------------------------------------------+
|i11 : SES = complex{                                                         |
|          map(comodule J, comodule I, 1),                                    |
|          map(comodule I, (comodule K) ** R^{-3}, {{a*b*c}})                 |
|          }                                                                  |
|                                                                             |
|o11 = cokernel | a3 b3 c3 abc | <-- cokernel | a3 b3 c3 | <-- cokernel {3} | |
|                                                                             |
|      0                             1                         2              |
|                                                                             |
|o11 : Complex                                                                |
|-----------------------------------------------------------------------------|
|c2 b2 a2 |                                                                   |
+-----------------------------------------------------------------------------+
|i12 : assert isWellDefined SES                                               |
+-----------------------------------------------------------------------------+
|i13 : assert isShortExactSequence(dd^SES_1, dd^SES_2)                        |
+-----------------------------------------------------------------------------+
|i14 : (g,f) = horseshoeResolution SES                                        |
|                                                                             |
|            1               2                             2                  |
|o14 = (0 : R  <----------- R  : 0                  , 0 : R                   |
|                 | 0 1 |                                                     |
|                                                                             |
|            4                             7                                  |
|       1 : R  <------------------------- R  : 1           7                  |
|                 {3} | 0 0 0 1 0 0 0 |               1 : R                   |
|                 {3} | 0 0 0 0 1 0 0 |                                       |
|                 {3} | 0 0 0 0 0 1 0 |                                       |
|                 {3} | 0 0 0 0 0 0 1 |                                       |
|                                                                             |
|            6                                 9                              |
|       2 : R  <----------------------------- R  : 2                          |
|                 {5} | 0 0 0 1 0 0 0 0 0 |                                   |
|                 {5} | 0 0 0 0 1 0 0 0 0 |                                   |
|                 {5} | 0 0 0 0 0 1 0 0 0 |                9                  |
|                 {6} | 0 0 0 0 0 0 1 0 0 |           2 : R                   |
|                 {6} | 0 0 0 0 0 0 0 1 0 |                                   |
|                 {6} | 0 0 0 0 0 0 0 0 1 |                                   |
|                                                                             |
|            3                       4                                        |
|       3 : R  <------------------- R  : 3                                    |
|                 {7} | 0 1 0 0 |                                             |
|                 {7} | 0 0 1 0 |                                             |
|                 {7} | 0 0 0 1 |                                             |
|                                                                             |
|                                                                             |
|                                                          4                  |
|                                                     3 : R                   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      -----------------------------------------------------------------------|
|                      1                                                      |
|      <------------- R  : 0    )                                             |
|         {3} | 1 |                                                           |
|         {0} | 0 |                                                           |
|                                                                             |
|                          3                                                  |
|      <----------------- R  : 1                                              |
|         {5} | 1 0 0 |                                                       |
|         {5} | 0 1 0 |                                                       |
|         {5} | 0 0 1 |                                                       |
|         {3} | 0 0 0 |                                                       |
|         {3} | 0 0 0 |                                                       |
|         {3} | 0 0 0 |                                                       |
|         {3} | 0 0 0 |                                                       |
|                                                                             |
|                          3                                                  |
|      <----------------- R  : 2                                              |
|         {7} | 1 0 0 |                                                       |
|         {7} | 0 1 0 |                                                       |
|         {7} | 0 0 1 |                                                       |
|         {5} | 0 0 0 |                                                       |
|         {5} | 0 0 0 |                                                       |
|         {5} | 0 0 0 |                                                       |
|         {6} | 0 0 0 |                                                       |
|         {6} | 0 0 0 |                                                       |
|         {6} | 0 0 0 |                                                       |
|                                                                             |
|                      1                                                      |
|      <------------- R  : 3                                                  |
|         {9} | 1 |                                                           |
|         {7} | 0 |                                                           |
|         {7} | 0 |                                                           |
|         {7} | 0 |                                                           |
|                                                                             |
|o14 : Sequence                                                               |
+-----------------------------------------------------------------------------+
|i15 : assert isShortExactSequence(g,f)                                       |
+-----------------------------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * isShortExactSequence(Complex), --
    whether a chain complex is a short exact sequence
  * canonicalMap -- gets the natural map arising from
    various constructions
  * cone(ComplexMap) -- make the mapping cone of a
    morphism of chain complexes
  * horseshoeResolution(Complex), --
    make the horseshoe resolution
  * longExactSequence(ComplexMap,ComplexMap)
    -- make the long exact
    sequence in homology

Ways to use this method:
========================

  * isShortExactSequence(ComplexMap,ComplexMap)
    -- whether a pair of
    complex maps forms a short exact sequence

isShortExactSequence(Matrix,Matrix) -- whether a pair of matrices forms a short exact sequence
**********************************************************************************************

Synopsis
========

  * Function: isShortExactSequence,
  * Usage:
        isShortExactSequence(g, f)
  * Inputs:
      * f, a matrix (Macaulay2Doc),
      * g, a matrix (Macaulay2Doc),
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true (Macaulay2Doc),
        if these form a short exact sequence

Description
===========

A short exact sequence of modules \[ 0 \to L \xrightarrow{f} M \xrightarrow{g}
N \to 0\] consists of two homomorphisms of modules $f \colon L \to M$ and $g
\colon M \to N$ such that $g f = 0$, $\operatorname{image} f =
\operatorname{ker} g$, $\operatorname{ker} f = 0$, and $\operatorname{coker} g
= 0$.

From a homomorphism $h \colon M \to N$, one obtains a short exact sequence \[ 0
\to \operatorname{image} h \to N \to \operatorname{coker} h \to 0. \]

+------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c];                                     |
+------------------------------------------------------------+
|i2 : h = random(R^3, R^{4:-1})                              |
|                                                            |
|o2 = | 24a-36b-30c  -22a-29b-24c -47a-39b-18c 2a+16b+22c   ||
|     | -29a+19b+19c -38a-16b+39c -13a-43b-15c 45a-34b-48c  ||
|     | -10a-29b-8c  21a+34b+19c  -28a-47b+38c -47a+47b+19c ||
|                                                            |
|             3       4                                      |
|o2 : Matrix R  <--- R                                       |
+------------------------------------------------------------+
|i3 : f = inducedMap(target h, image h)                      |
|                                                            |
|o3 = | 24a-36b-30c  -22a-29b-24c -47a-39b-18c 2a+16b+22c   ||
|     | -29a+19b+19c -38a-16b+39c -13a-43b-15c 45a-34b-48c  ||
|     | -10a-29b-8c  21a+34b+19c  -28a-47b+38c -47a+47b+19c ||
|                                                            |
|o3 : Matrix                                                 |
+------------------------------------------------------------+
|i4 : g = inducedMap(cokernel h, target h)                   |
|                                                            |
|o4 = | 1 0 0 |                                              |
|     | 0 1 0 |                                              |
|     | 0 0 1 |                                              |
|                                                            |
|o4 : Matrix                                                 |
+------------------------------------------------------------+
|i5 : assert isShortExactSequence(g,f)                       |
+------------------------------------------------------------+

Ideal quotients also give rise to short exact sequences.

+------------------------------------------------------------+
|i6 : I = ideal(a^3, b^3, c^3)                               |
|                                                            |
|             3   3   3                                      |
|o6 = ideal (a , b , c )                                     |
|                                                            |
|o6 : Ideal of R                                             |
+------------------------------------------------------------+
|i7 : J = I + ideal(a*b*c)                                   |
|                                                            |
|             3   3   3                                      |
|o7 = ideal (a , b , c , a*b*c)                              |
|                                                            |
|o7 : Ideal of R                                             |
+------------------------------------------------------------+
|i8 : K = I : ideal(a*b*c)                                   |
|                                                            |
|             2   2   2                                      |
|o8 = ideal (c , b , a )                                     |
|                                                            |
|o8 : Ideal of R                                             |
+------------------------------------------------------------+
|i9 : g = map(comodule J, comodule I, 1)                     |
|                                                            |
|o9 = | 1 |                                                  |
|                                                            |
|o9 : Matrix                                                 |
+------------------------------------------------------------+
|i10 : f = map(comodule I, (comodule K) ** R^{-3}, {{a*b*c}})|
|                                                            |
|o10 = | abc |                                               |
|                                                            |
|o10 : Matrix                                                |
+------------------------------------------------------------+
|i11 : assert isShortExactSequence(g,f)                      |
+------------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * isShortExactSequence(Complex), --
    whether a chain complex is a short exact sequence
  * isShortExactSequence(ComplexMap,ComplexMap)
    -- whether a pair of
    complex maps forms a short exact sequence

Ways to use this method:
========================

  * isShortExactSequence(Matrix,Matrix)
    -- whether a pair of matrices
    forms a short exact sequence

isWellDefined(Complex) -- whether a complex is well-defined
***********************************************************

Synopsis
========

  * Function: isWellDefined (Macaulay2Doc),
  * Usage:
        isWellDefined C
  * Inputs:
      * C, a complex,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when C
        determines a well defined complex

Description
===========

This routine checks that the differential of C composes to zero. Additionally,
it checks that the underlying data in C is a properly formed Complex object in
Macaulay2. If the variable debugLevel is set to a value greater than zero, then
information about the nature of any failure is displayed.

As a first example, we construct by hand the free resolution of the twisted
cubic.  One must work with maps rather than matrices, because the source and
the target of adjacent maps must be the same (including degree information).

+---------------------------------------------------+
|i1 : R = QQ[a..d];                                 |
+---------------------------------------------------+
|i2 : f0 = matrix {{-b^2+a*c, b*c-a*d, -c^2+b*d}}   |
|                                                   |
|o2 = | -b2+ac bc-ad -c2+bd |                       |
|                                                   |
|             1       3                             |
|o2 : Matrix R  <--- R                              |
+---------------------------------------------------+
|i3 : f1 = map(source f0,, {{d, c}, {c, b}, {b, a}})|
|                                                   |
|o3 = {2} | d c |                                   |
|     {2} | c b |                                   |
|     {2} | b a |                                   |
|                                                   |
|             3       2                             |
|o3 : Matrix R  <--- R                              |
+---------------------------------------------------+
|i4 : C = complex {f0, f1}                          |
|                                                   |
|      1      3      2                              |
|o4 = R  <-- R  <-- R                               |
|                                                   |
|     0      1      2                               |
|                                                   |
|o4 : Complex                                       |
+---------------------------------------------------+
|i5 : isWellDefined C                               |
|                                                   |
|o5 = true                                          |
+---------------------------------------------------+
|i6 : dd^C                                          |
|                                                   |
|          1                               3        |
|o6 = 0 : R  <--------------------------- R  : 1    |
|               | -b2+ac bc-ad -c2+bd |             |
|                                                   |
|          3                   2                    |
|     1 : R  <--------------- R  : 2                |
|               {2} | d c |                         |
|               {2} | c b |                         |
|               {2} | b a |                         |
|                                                   |
|o6 : ComplexMap                                    |
+---------------------------------------------------+
|i7 : (dd^C)^2                                      |
|                                                   |
|o7 = 0                                             |
|                                                   |
|o7 : ComplexMap                                    |
+---------------------------------------------------+

The zero complex is well-defined.

+--------------------+
|i8 : C = complex R^0|
|                    |
|o8 = 0              |
|                    |
|     0              |
|                    |
|o8 : Complex        |
+--------------------+
|i9 : isWellDefined C|
|                    |
|o9 = true           |
+--------------------+

The next example demonstrates the case when the sequence maps do not compose to
0.

+--------------------------------------------------------+
|i10 : g1 = map(source f0,, {{-d, c}, {c, b}, {b, a}})   |
|                                                        |
|o10 = {2} | -d c |                                      |
|      {2} | c  b |                                      |
|      {2} | b  a |                                      |
|                                                        |
|              3       2                                 |
|o10 : Matrix R  <--- R                                  |
+--------------------------------------------------------+
|i11 : C = complex {f0, g1}                              |
|                                                        |
|       1      3      2                                  |
|o11 = R  <-- R  <-- R                                   |
|                                                        |
|      0      1      2                                   |
|                                                        |
|o11 : Complex                                           |
+--------------------------------------------------------+
|i12 : isWellDefined C                                   |
|                                                        |
|o12 = false                                             |
+--------------------------------------------------------+
|i13 : debugLevel = 1                                    |
|                                                        |
|o13 = 1                                                 |
+--------------------------------------------------------+
|i14 : isWellDefined C                                   |
|-- expected maps in the differential to compose to zero |
|--   differentials at indices (2, 1) fail this condition|
|                                                        |
|o14 = false                                             |
+--------------------------------------------------------+
|i15 : (dd^C)^2                                          |
|                                                        |
|           1                       2                    |
|o15 = 0 : R  <------------------- R  : 2                |
|                | 2b2d-2acd 0 |                         |
|                                                        |
|o15 : ComplexMap                                        |
+--------------------------------------------------------+

See also
========

  * isWellDefined(ComplexMap) -- whether
    a map of chain complexes is well-defined
  * map (Macaulay2Doc) -- make a map

Ways to use this method:
========================

  * isWellDefined(Complex) -- whether a
    complex is well-defined

isWellDefined(ComplexMap) -- whether a map of chain complexes is well-defined
*****************************************************************************

Synopsis
========

  * Function: isWellDefined (Macaulay2Doc),
  * Usage:
        isWellDefined f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * a Boolean value (Macaulay2Doc), that is true when f
        determines a well defined complex map

Description
===========

A map of chain complexes $f : C \to D$ of degree $d$ is a sequence of maps $f_i
: C_i \to D_{d+i}$.  No relationship is required between these maps and the
differentials in the source and target.

This routine checks that $C$ and $D$ are well-defined chain complexes, and
that, for each $f_i$, the source and target equal $C_i$ and $D_{d+i}$,
respectively.  If the variable debugLevel is set to a value greater than zero,
then information about the nature of any failure is displayed.

Unlike the corresponding function for Complexes,
the basic constructors for complex maps are all
but assured to be well defined. The only case that could cause a problem is if
one constructs the source or target complex, and those are not well defined.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c];                                                      |
+-----------------------------------------------------------------------------+
|i2 : C = freeResolution coker matrix{{a^2-b^2,b^3-c^3,c^4}}                  |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : D = freeResolution coker vars R                                         |
|                                                                             |
|      1      3      3      1                                                 |
|o3 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : H = hashTable { 0 => map(D_0, C_0, 1),                                  |
|         1 => map(D_1, C_1, {{a, 0, 0}, {-b, b^2, 0}, {0, -c^2, c^3}}),      |
|         2 => map(D_2, C_2, {{a*b^2, 0, 0}, {-a*c^2, a*c^3, 0}, {b*c^2,      |
|         3 => map(D_3, C_3, {{a*b^2*c^3}})                                   |
|         }                                                                   |
|                                                                             |
|o4 = HashTable{0 => | 1 |                 }                                  |
|               1 => {1} | a  0   0  |                                        |
|                    {1} | -b b2  0  |                                        |
|                    {1} | 0  -c2 c3 |                                        |
|               2 => {2} | ab2  0    0    |                                   |
|                    {2} | -ac2 ac3  0    |                                   |
|                    {2} | bc2  -bc3 b2c3 |                                   |
|               3 => {3} | ab2c3 |                                            |
|                                                                             |
|o4 : HashTable                                                               |
|-----------------------------------------------------------------------------|
|-b*c^3, b^2*c^3}}),                                                          |
+-----------------------------------------------------------------------------+
|i5 : f = map(D, C, H)                                                        |
|                                                                             |
|          1             1                                                    |
|o5 = 0 : R  <--------- R  : 0                                                |
|               | 1 |                                                         |
|                                                                             |
|          3                         3                                        |
|     1 : R  <--------------------- R  : 1                                    |
|               {1} | a  0   0  |                                             |
|               {1} | -b b2  0  |                                             |
|               {1} | 0  -c2 c3 |                                             |
|                                                                             |
|          3                              3                                   |
|     2 : R  <-------------------------- R  : 2                               |
|               {2} | ab2  0    0    |                                        |
|               {2} | -ac2 ac3  0    |                                        |
|               {2} | bc2  -bc3 b2c3 |                                        |
|                                                                             |
|          1                     1                                            |
|     3 : R  <----------------- R  : 3                                        |
|               {3} | ab2c3 |                                                 |
|                                                                             |
|o5 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i6 : assert isWellDefined f                                                  |
+-----------------------------------------------------------------------------+
|i7 : assert isHomogeneous f                                                  |
+-----------------------------------------------------------------------------+
|i8 : assert(degree f == 0)                                                   |
+-----------------------------------------------------------------------------+
|i9 : assert isComplexMorphism f                                              |
+-----------------------------------------------------------------------------+

We construct two random maps of chain complexes, and check to see that, as
should be the case, both are well defined.

+-----------------------------------------------------------------------------+
|i10 : g = randomComplexMap(D,C)                                              |
|                                                                             |
|           1              1                                                  |
|o10 = 0 : R  <---------- R  : 0                                              |
|                | 24 |                                                       |
|                                                                             |
|           3                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {1} | -36a-30b-29c -29a2-24ab-16b2-38ac+39bc+21c2 16a3+22a2b-|
|                {1} | 19a+19b-10c  34a2+19ab-39b2-47ac-18bc-13c2  15a3-23a2b+|
|                {1} | -29a-8b-22c  -43a2-15ab-47b2-28ac+38bc+2c2  -38a3+33a2b|
|                                                                             |
|           3                                                                 |
|      2 : R  <---------------------------------------------------------------|
|                {2} | -23a3-7a2b+29ab2-37b3+2a2c-47abc-13b2c+15ac2-10bc2+30c3|
|                {2} | -18a3+39a2b-22ab2-32b3+27a2c+32abc-20b2c-9ac2+24bc2-30c|
|                {2} | -48a3-15a2b-33b3+39a2c+33abc-19b2c-49ac2+17bc2-20c3    |
|                                                                             |
|           1                                                                 |
|      3 : R  <---------------------------------------------------------------|
|                {3} | 4a6+22a5b-20a4b2+15a3b3+9a2b4+16ab5-30b6+5a5c-13a4bc-4a|
|                                                                             |
|o10 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                   3                         |
|------------------------------------------------- R  : 1                     |
|34ab2+47b3+45a2c-48abc+19b2c-47ac2-16bc2+7c3  |                              |
|43ab2+48b3+39a2c-17abc+36b2c-11ac2+35bc2+11c3 |                              |
|+11ab2+b3+40a2c+46abc-3b2c-28ac2+22bc2-47c3   |                              |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|  44a4-39a3b+9a2b2+13ab3-11b4+36a3c-39a2bc-26ab2c-8b3c+4a2c2+22abc2+43b2c2-49|
|3 -3a4-22a3b+41a2b2-6ab3+6b4-30a3c+16a2bc+35ab2c+40b3c-28a2c2-9abc2+3b2c2-35a|
|  -2a4-41a3b-13a2b2-47ab3-35b4-49a3c+4a2bc+27ab2c-31b3c+30a2c2-40abc2-39b2c2+|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|3b2c-2a2b3c+10ab4c-4b5c-29a4c2+12a3bc2+20a2b2c2+31ab3c2-14b4c2+3a3c3-26a2bc3+|
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|ac3-8bc3+36c4    -29a5-48a4b-37a3b2+28a2b3+40ab4+13b5+30a4c+47a3bc-18a2b2c-22|
|c3-31bc3+25c4    8a5-29a4b-46a3b2+42a2b3+18ab4+27b5+30a4c+49a3bc+23a2b2c-16ab|
|37ac3-31bc3-48c4 -39a5+20a4b+47a2b3-33ab4-37b5+19a4c-47a3bc-28a2b2c+28ab3c-33|
|                                                                             |
|                                                        1                    |
|------------------------------------------------------ R  : 3                |
|28ab2c3-33b3c3+33a2c4-6abc4-42b2c4+21ac5-44bc5-5c6 |                         |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|ab3c-17b4c-49a3c2+46a2bc2+10ab2c2-13b3c2+a2c3+7abc3+3b2c3+30ac4-41bc4+8c5    |
|3c-21b4c-18a3c2-28a2bc2-46ab2c2+23b3c2+15a2c3+12abc3-37b2c3-18ac4-23bc4+44c5 |
|b4c-28a3c2+6a2bc2-29ab2c2-28b3c2-9a2c3+26abc3+42b2c3+5ac4+44bc4+30c5         |
|-----------------------------------------------------------------------------|
|     3                                                                       |
|--- R  : 2                                                                   |
||                                                                            |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i11 : assert isWellDefined g                                                 |
+-----------------------------------------------------------------------------+
|i12 : assert not isCommutative g                                             |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
|i13 : h = randomComplexMap(D,C, Cycle => true)                               |
|                                                                             |
|           1               1                                                 |
|o13 = 0 : R  <----------- R  : 0                                             |
|                | -17 |                                                      |
|                                                                             |
|           3                                                                 |
|      1 : R  <---------------------------------------------------------------|
|                {1} | -17a-29b-44c -49ab-b2+48ac-50bc-40c2        33a2b-9ab2+|
|                {1} | 29a+17b-42c  49a2+ab-17b2+11ac+19bc-45c2    -33a3+9a2b-|
|                {1} | 44a+42b      -48a2+39ab-19b2+40ac+45bc+17c2 43a3+6a2b+2|
|                                                                             |
|           3                                                                 |
|      2 : R  <---------------------------------------------------------------|
|                {2} | 49a3+a2b+35ab2-30b3-a2c+37abc+48b2c+34ac2+16bc2-2c3    |
|                {2} | -48a3-50a2b+11ab2-41b3+40a2c-34abc+45b2c+17ac2+31bc2+44|
|                {2} | -12a3+18a2b-42ab2-23b3-22a2c+16abc-45b2c-31ac2-17bc2+42|
|                                                                             |
|           1                                                                 |
|      3 : R  <---------------------------------------------------------------|
|                {3} | -16a6-35a5b+12a4b2+7a3b3+46a2b4+8ab5+5b6-39a5c-24a4bc+1|
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                3                            |
|---------------------------------------------- R  : 1                        |
|46b3-43a2c+35abc+27b2c+50ac2+45bc2+49c3    |                                 |
|46ab2-41a2c-29abc-36b2c-47ac2+40bc2-45c3   |                                 |
|ab2+36b3-50a2c+2abc-40b2c-49ac2+45bc2-17c3 |                                 |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|   -33a4+9a3b-13a2b2-9ab3+46b4+21a3c-40a2bc-ab2c-7b3c-8a2c2-42abc2-44b2c2-49a|
|c3 43a4+45a3b-30a2b2+36ab3+34b4-50a3c-37a2bc-9ab2c-12b3c-49a2c2+49abc2+23b2c2|
|c3 -39a4-11a3b-6a2b2-36ab3-36b4+39a3c+19a2bc+10ab2c+40b3c-4a2c2+26abc2-45b2c2|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|6a3b2c+13a2b3c-36ab4c-38b5c-32a4c2-18a3bc2-13a2b2c2-34ab3c2+19b4c2-46a3c3-24a|
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|c3+26bc3+44c4     -33a2b3+9ab4-46b5-16a4c-35a3bc-4a2b2c-7ab3c+2b4c-39a3c2-24a|
|-17ac3+28bc3-44c4 16a4b+35a3b2+47a2b3-28ab4-29b5+39a3bc+24a2b2c-27ab3c-26b4c+|
|-28ac3+17bc3-42c4 -16a5-35a4b-4a3b2+34a2b3+31ab4+36b5-39a4c-24a3bc-23a2b2c+28|
|                                                                             |
|                                                             1               |
|----------------------------------------------------------- R  : 3           |
|2bc3+49ab2c3+5b3c3-48a2c4-5abc4+43b2c4-15ac5+42bc5+42c6 |                    |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|2bc2-23ab2c2-19b3c2+a2c3-27abc3+b2c3-15ac4+15bc4-39c5                        |
|32a2bc2+18ab2c2-4b3c2-43a2c3+abc3+11b2c3-3ac4+34bc4+9c5                      |
|ab3c-40b4c-32a3c2-18a2bc2-45ab2c2+45b3c2-7a2c3-13abc3+48b2c3+26ac4-42bc4+11c5|
|-----------------------------------------------------------------------------|
|      3                                                                      |
|---- R  : 2                                                                  |
| |                                                                           |
| |                                                                           |
| |                                                                           |
+-----------------------------------------------------------------------------+
|i14 : assert isWellDefined h                                                 |
+-----------------------------------------------------------------------------+
|i15 : assert isComplexMorphism h                                             |
+-----------------------------------------------------------------------------+

This method also checks the following aspects of the data structure:

  * The underlying hash table has exactly the expected keys, namely, source,
    target, degree, map, cache
  * The ring of the source and target are the same
  * The source and target are well defined complexes
  * The degree is an integer
  * All keys in the map field are integers, in the range of the concentration
    of the source
  * The source and target of each $f_i$ is as expected
  * If the isCommutative key is present in the cache table, then commutativity
    of the map with the differentials is checked

See also
========

  * isWellDefined(Complex) -- whether a
    complex is well-defined
  * isCommutative(ComplexMap) -- whether
    a complex map commutes with the differentials
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes
  * map(Complex,Complex,HashTable)
    -- make a map of chain complexes

Ways to use this method:
========================

  * isWellDefined(ComplexMap) -- whether
    a map of chain complexes is well-defined

kernel(ComplexMap) -- make the kernel of a map of complexes
***********************************************************

Synopsis
========

  * Function: kernel (Macaulay2Doc),
  * Usage:
        kernel f
        ker f
  * Inputs:
      * f, a map of complexes,
  * Optional inputs (Macaulay2Doc),:
      * SubringLimit (Macaulay2Doc),
        => ..., default value infinity, null
  * Outputs:
      * a complex,

Description
===========

The kernel of a chain complex map $f : C \to D$ is the complex $E$ whose $i-th$
term is $kernel(f_i)$, and whose differential is induced from the differential
on the source.

In the following example, we first construct a random complex morphism $f : C
\to D$.  We consider the exact sequence $0 \to D \to cone(f) \to C[-1] \to 0$.
For the maps $g : D \to cone(f)$ and $h : cone(f) \to C[-1]$, we compute the
kernel.

+--------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c,d];                                           |
+--------------------------------------------------------------------+
|i2 : C = freeResolution ideal(b^2-a*c, b*c-a*d, c^2-b*d)            |
|                                                                    |
|      1      3      2                                               |
|o2 = S  <-- S  <-- S                                                |
|                                                                    |
|     0      1      2                                                |
|                                                                    |
|o2 : Complex                                                        |
+--------------------------------------------------------------------+
|i3 : D = freeResolution ideal(a,b,c)                                |
|                                                                    |
|      1      3      3      1                                        |
|o3 = S  <-- S  <-- S  <-- S                                         |
|                                                                    |
|     0      1      2      3                                         |
|                                                                    |
|o3 : Complex                                                        |
+--------------------------------------------------------------------+
|i4 : f = randomComplexMap(D, C, Cycle => true, InternalDegree => 0) |
|                                                                    |
|          1               1                                         |
|o4 = 0 : S  <----------- S  : 0                                     |
|               | -22 |                                              |
|                                                                    |
|          3                                                    3    |
|     1 : S  <------------------------------------------------ S  : 1|
|               {1} | 36b+3c       30b-19c+22d -29b-10c    |         |
|               {1} | -36a-22b+29c -30a-14c    29a+29c+22d |         |
|               {1} | 19a-29b      19a-8b      10a-29b-22c |         |
|                                                                    |
|          3                                                 2       |
|     2 : S  <--------------------------------------------- S  : 2   |
|               {2} | -29a-30b+31c-22d 29b+6c-36d       |            |
|               {2} | -10a+24b+3c      34b-19c+19d      |            |
|               {2} | 24a-8b+29c       -24a-29b-14c-29d |            |
|                                                                    |
|o4 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i5 : Cf = cone f                                                    |
|                                                                    |
|      1      4      6      3                                        |
|o5 = S  <-- S  <-- S  <-- S                                         |
|                                                                    |
|     0      1      2      3                                         |
|                                                                    |
|o5 : Complex                                                        |
+--------------------------------------------------------------------+
|i6 : g = canonicalMap(Cf, D)                                        |
|                                                                    |
|          1             1                                           |
|o6 = 0 : S  <--------- S  : 0                                       |
|               | 1 |                                                |
|                                                                    |
|          4                     3                                   |
|     1 : S  <----------------- S  : 1                               |
|               {0} | 0 0 0 |                                        |
|               {1} | 1 0 0 |                                        |
|               {1} | 0 1 0 |                                        |
|               {1} | 0 0 1 |                                        |
|                                                                    |
|          6                     3                                   |
|     2 : S  <----------------- S  : 2                               |
|               {2} | 0 0 0 |                                        |
|               {2} | 0 0 0 |                                        |
|               {2} | 0 0 0 |                                        |
|               {2} | 1 0 0 |                                        |
|               {2} | 0 1 0 |                                        |
|               {2} | 0 0 1 |                                        |
|                                                                    |
|          3                 1                                       |
|     3 : S  <------------- S  : 3                                   |
|               {3} | 0 |                                            |
|               {3} | 0 |                                            |
|               {3} | 1 |                                            |
|                                                                    |
|o6 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i7 : h = canonicalMap(C[-1], Cf)                                    |
|                                                                    |
|          1                   4                                     |
|o7 = 1 : S  <--------------- S  : 1                                 |
|               | 1 0 0 0 |                                          |
|                                                                    |
|          3                           6                             |
|     2 : S  <----------------------- S  : 2                         |
|               {2} | 1 0 0 0 0 0 |                                  |
|               {2} | 0 1 0 0 0 0 |                                  |
|               {2} | 0 0 1 0 0 0 |                                  |
|                                                                    |
|          2                     3                                   |
|     3 : S  <----------------- S  : 3                               |
|               {3} | 1 0 0 |                                        |
|               {3} | 0 1 0 |                                        |
|                                                                    |
|o7 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i8 : ker g == 0                                                     |
|                                                                    |
|o8 = true                                                           |
+--------------------------------------------------------------------+
|i9 : prune ker h == D                                               |
|                                                                    |
|o9 = true                                                           |
+--------------------------------------------------------------------+

There is a canonical map of complexes from the kernel to the source.

+-------------------------------------------------------+
|i10 : h1 = canonicalMap(source h, ker h)               |
|                                                       |
|           1             1                             |
|o10 = 0 : S  <--------- S  : 0                         |
|                | 1 |                                  |
|                                                       |
|           4                                           |
|      1 : S  <----------------- image {0} | 0 0 0 | : 1|
|                {0} | 0 0 0 |         {1} | 1 0 0 |    |
|                {1} | 1 0 0 |         {1} | 0 1 0 |    |
|                {1} | 0 1 0 |         {1} | 0 0 1 |    |
|                {1} | 0 0 1 |                          |
|                                                       |
|           6                                           |
|      2 : S  <----------------- image {2} | 0 0 0 | : 2|
|                {2} | 0 0 0 |         {2} | 0 0 0 |    |
|                {2} | 0 0 0 |         {2} | 0 0 0 |    |
|                {2} | 0 0 0 |         {2} | 1 0 0 |    |
|                {2} | 1 0 0 |         {2} | 0 1 0 |    |
|                {2} | 0 1 0 |         {2} | 0 0 1 |    |
|                {2} | 0 0 1 |                          |
|                                                       |
|           3                                           |
|      3 : S  <------------- image {3} | 0 | : 3        |
|                {3} | 0 |         {3} | 0 |            |
|                {3} | 0 |         {3} | 1 |            |
|                {3} | 1 |                              |
|                                                       |
|o10 : ComplexMap                                       |
+-------------------------------------------------------+
|i11 : ker h == image h1                                |
|                                                       |
|o11 = true                                             |
+-------------------------------------------------------+
|i12 : ker h1 == 0                                      |
|                                                       |
|o12 = true                                             |
+-------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * kernel (Macaulay2Doc) -- kernel of a ringmap, matrix, or
    chain complex
  * image(ComplexMap) -- make the image of a map
    of complexes
  * coimage(ComplexMap) -- make the coimage of
    a map of complexes
  * cokernel(ComplexMap) -- make the cokernel
    of a map of complexes
  * canonicalMap -- gets the natural map arising from
    various constructions

Ways to use this method:
========================

  * kernel(ComplexMap) -- make the kernel of a
    map of complexes

koszulComplex(Matrix) -- makes the Koszul complex
*************************************************

Synopsis
========

  * Function: koszulComplex,
  * Usage:
        K = koszulComplex f
  * Inputs:
      * f, a matrix (Macaulay2Doc), having one row, or a a
        list (Macaulay2Doc), of ring elements
  * Optional inputs (Macaulay2Doc),:
      * Concentration => a sequence (Macaulay2Doc), default
        value null, a pair (lo, hi) which limits the non-zero terms in the
        output
  * Outputs:
      * a complex, the Koszul complex (or a subcomplex)

Description
===========

Let $R$ be a commutative ring and let $E$ be a free $R$-module of finite rank
$r$. Given a linear map $f \colon E \to R$, the Koszul complex associated to
$f$ is the chain complex of $R$-modules

$\phantom{WWWW} 0 \leftarrow R \leftarrow \bigwedge^1 E \leftarrow \bigwedge^2
E \leftarrow \dotsb \leftarrow \bigwedge^r E \leftarrow 0, $

where the differential is given by

$\phantom{WWWW} dd_k(e_1 \wedge e_2 \wedge \dotsb \wedge e_k) = \sum_{i=1}^k
(-1)^{i+1} f(e_i) \, e_1 \wedge e_2 \wedge \dotsb \wedge \widehat{e_i} \wedge
\dotsb \wedge e_k, $

and the superscript hat means the term is omitted.  For this method, the linear
map $f$ is given as either a matrix with one row, or a list of ring elements.

+-------------------------------------------------+
|i1 : S = QQ[a..d]                                |
|                                                 |
|o1 = S                                           |
|                                                 |
|o1 : PolynomialRing                              |
+-------------------------------------------------+
|i2 : koszulComplex {a}                           |
|                                                 |
|      1      1                                   |
|o2 = S  <-- S                                    |
|                                                 |
|     0      1                                    |
|                                                 |
|o2 : Complex                                     |
+-------------------------------------------------+
|i3 : C = koszulComplex {a^2+b^2,c^3}             |
|                                                 |
|      1      2      1                            |
|o3 = S  <-- S  <-- S                             |
|                                                 |
|     0      1      2                             |
|                                                 |
|o3 : Complex                                     |
+-------------------------------------------------+
|i4 : dd^C                                        |
|                                                 |
|          1                    2                 |
|o4 = 0 : S  <---------------- S  : 1             |
|               | a2+b2 c3 |                      |
|                                                 |
|          2                     1                |
|     1 : S  <----------------- S  : 2            |
|               {2} | -c3   |                     |
|               {3} | a2+b2 |                     |
|                                                 |
|o4 : ComplexMap                                  |
+-------------------------------------------------+
|i5 : K4 = koszulComplex vars S                   |
|                                                 |
|      1      4      6      4      1              |
|o5 = S  <-- S  <-- S  <-- S  <-- S               |
|                                                 |
|     0      1      2      3      4               |
|                                                 |
|o5 : Complex                                     |
+-------------------------------------------------+
|i6 : dd^K4                                       |
|                                                 |
|          1                   4                  |
|o6 = 0 : S  <--------------- S  : 1              |
|               | a b c d |                       |
|                                                 |
|          4                                 6    |
|     1 : S  <----------------------------- S  : 2|
|               {1} | -b -c 0  -d 0  0  |         |
|               {1} | a  0  -c 0  -d 0  |         |
|               {1} | 0  a  b  0  0  -d |         |
|               {1} | 0  0  0  a  b  c  |         |
|                                                 |
|          6                           4          |
|     2 : S  <----------------------- S  : 3      |
|               {2} | c  d  0  0  |               |
|               {2} | -b 0  d  0  |               |
|               {2} | a  0  0  d  |               |
|               {2} | 0  -b -c 0  |               |
|               {2} | 0  a  0  -c |               |
|               {2} | 0  0  a  b  |               |
|                                                 |
|          4                  1                   |
|     3 : S  <-------------- S  : 4               |
|               {3} | -d |                        |
|               {3} | c  |                        |
|               {3} | -b |                        |
|               {3} | a  |                        |
|                                                 |
|o6 : ComplexMap                                  |
+-------------------------------------------------+
|i7 : assert isWellDefined K4                     |
+-------------------------------------------------+

To obtain natural subcomplexes, use the Concentration option.

+---------------------------------------------------+
|i8 : koszulComplex(vars S, Concentration => (2,3)) |
|                                                   |
|      6      4                                     |
|o8 = S  <-- S                                      |
|                                                   |
|     2      3                                      |
|                                                   |
|o8 : Complex                                       |
+---------------------------------------------------+
|i9 : koszulComplex(vars S, Concentration => (-1,5))|
|                                                   |
|      1      4      6      4      1                |
|o9 = S  <-- S  <-- S  <-- S  <-- S                 |
|                                                   |
|     0      1      2      3      4                 |
|                                                   |
|o9 : Complex                                       |
+---------------------------------------------------+

The koszul complex can be constructed as an iterated tensor product. The maps
are identical, except that the even indexed differentials have the opposite
sign.

+-----------------------------------------------------------------------------+
|i10 : C = koszulComplex {d} ** (koszulComplex {c} ** (koszulComplex {b} **   |
|                                                                             |
|       1      4      6      4      1                                         |
|o10 = S  <-- S  <-- S  <-- S  <-- S                                          |
|                                                                             |
|      0      1      2      3      4                                          |
|                                                                             |
|o10 : Complex                                                                |
|-----------------------------------------------------------------------------|
|koszulComplex {a}))                                                          |
+-----------------------------------------------------------------------------+
|i11 : K = koszulComplex {a,b,c,d}                                            |
|                                                                             |
|       1      4      6      4      1                                         |
|o11 = S  <-- S  <-- S  <-- S  <-- S                                          |
|                                                                             |
|      0      1      2      3      4                                          |
|                                                                             |
|o11 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i12 : netList {{dd^C, dd^K}}                                                 |
|                                                                             |
|      +--------------------------------------------+-------------------------|
|      |     1                   4                  |     1                   |
|o12 = |0 : S  <--------------- S  : 1              |0 : S  <--------------- S|
|      |          | a b c d |                       |          | a b c d |    |
|      |                                            |                         |
|      |     4                                 6    |     4                   |
|      |1 : S  <----------------------------- S  : 2|1 : S  <-----------------|
|      |          {1} | b  c  0  d  0  0  |         |          {1} | -b -c 0  |
|      |          {1} | -a 0  c  0  d  0  |         |          {1} | a  0  -c |
|      |          {1} | 0  -a -b 0  0  d  |         |          {1} | 0  a  b  |
|      |          {1} | 0  0  0  -a -b -c |         |          {1} | 0  0  0  |
|      |                                            |                         |
|      |     6                           4          |     6                   |
|      |2 : S  <----------------------- S  : 3      |2 : S  <-----------------|
|      |          {2} | c  d  0  0  |               |          {2} | c  d  0  |
|      |          {2} | -b 0  d  0  |               |          {2} | -b 0  d  |
|      |          {2} | a  0  0  d  |               |          {2} | a  0  0  |
|      |          {2} | 0  -b -c 0  |               |          {2} | 0  -b -c |
|      |          {2} | 0  a  0  -c |               |          {2} | 0  a  0  |
|      |          {2} | 0  0  a  b  |               |          {2} | 0  0  a  |
|      |                                            |                         |
|      |     4                  1                   |     4                  1|
|      |3 : S  <-------------- S  : 4               |3 : S  <-------------- S |
|      |          {3} | d  |                        |          {3} | -d |     |
|      |          {3} | -c |                        |          {3} | c  |     |
|      |          {3} | b  |                        |          {3} | -b |     |
|      |          {3} | -a |                        |          {3} | a  |     |
|      +--------------------------------------------+-------------------------|
|-----------------------------------------------------------------------------|
|-------------------+                                                         |
|4                  |                                                         |
|  : 1              |                                                         |
|                   |                                                         |
|                   |                                                         |
|              6    |                                                         |
|------------ S  : 2|                                                         |
|-d 0  0  |         |                                                         |
|0  -d 0  |         |                                                         |
|0  0  -d |         |                                                         |
|a  b  c  |         |                                                         |
|                   |                                                         |
|        4          |                                                         |
|------ S  : 3      |                                                         |
|0  |               |                                                         |
|0  |               |                                                         |
|d  |               |                                                         |
|0  |               |                                                         |
|-c |               |                                                         |
|b  |               |                                                         |
|                   |                                                         |
|                   |                                                         |
| : 4               |                                                         |
|                   |                                                         |
|                   |                                                         |
|                   |                                                         |
|                   |                                                         |
|-------------------+                                                         |
+-----------------------------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Complex ** Complex -- tensor product of
    complexes

Ways to use this method:
========================

  * "koszulComplex(List)"
  * koszulComplex(Matrix) -- makes the Koszul
    complex

length(Complex) -- length of a complex
**************************************

Synopsis
========

  * Function: length (Macaulay2Doc),
  * Usage:
        length C
  * Inputs:
      * C, a complex,
  * Outputs:
      * an integer (Macaulay2Doc),

Description
===========

The length of a complex is the difference between the highest index of a
non-zero object and the lowest index of a non-zero object.

Typically, it counts the number of non-zero differentials, e.g. in a free
resolution.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c,d];                                                    |
+-----------------------------------------------------------------------------+
|i2 : C1 = freeResolution coker vars S                                        |
|                                                                             |
|      1      4      6      4      1                                          |
|o2 = S  <-- S  <-- S  <-- S  <-- S                                           |
|                                                                             |
|     0      1      2      3      4                                           |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : length C1                                                               |
|                                                                             |
|o3 = 4                                                                       |
+-----------------------------------------------------------------------------+
|i4 : C2 = C1[5]                                                              |
|                                                                             |
|      1      4      6      4      1                                          |
|o4 = S  <-- S  <-- S  <-- S  <-- S                                           |
|                                                                             |
|     -5     -4     -3     -2     -1                                          |
|                                                                             |
|o4 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i5 : length C2                                                               |
|                                                                             |
|o5 = 4                                                                       |
+-----------------------------------------------------------------------------+
|i6 : C3 = C1 ++ C1[6]                                                        |
|                                                                             |
|      1      4      6      4      1             1      4      6      4      1|
|o6 = S  <-- S  <-- S  <-- S  <-- S  <-- 0  <-- S  <-- S  <-- S  <-- S  <-- S |
|                                                                             |
|     -6     -5     -4     -3     -2     -1     0      1      2      3      4 |
|                                                                             |
|o6 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i7 : length C3                                                               |
|                                                                             |
|o7 = 10                                                                      |
+-----------------------------------------------------------------------------+

This function always prunes the input complex, so might involve computation.

+-----------------------------------------------------------------------------+
|i8 : M1 = S^1/(a*b, c*d, a*c, b*c)                                           |
|                                                                             |
|o8 = cokernel | ab cd ac bc |                                                |
|                                                                             |
|                            1                                                |
|o8 : S-module, quotient of S                                                 |
+-----------------------------------------------------------------------------+
|i9 : M2 = S^1/(a*b, c*d, a*c)                                                |
|                                                                             |
|o9 = cokernel | ab cd ac |                                                   |
|                                                                             |
|                            1                                                |
|o9 : S-module, quotient of S                                                 |
+-----------------------------------------------------------------------------+
|i10 : C4 = freeResolution M1                                                 |
|                                                                             |
|       1      4      4      1                                                |
|o10 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o10 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i11 : C5 = freeResolution M2                                                 |
|                                                                             |
|       1      3      2                                                       |
|o11 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o11 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i12 : f = map(M1, M2, 1)                                                     |
|                                                                             |
|o12 = | 1 |                                                                  |
|                                                                             |
|o12 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i13 : C6 = coker extend(C4, C5, matrix f)                                    |
|                                                                             |
|                                                                             |
|o13 = cokernel | 1 | <-- cokernel {2} | 1 0 0 | <-- cokernel {3} | 1 0 | <-- |
|                                  {2} | 0 1 0 |              {3} | 0 0 |     |
|      0                           {2} | 0 0 0 |              {3} | 0 1 |     |
|                                  {2} | 0 0 1 |              {3} | 0 0 |     |
|                                                                             |
|                         1                          2                        |
|                                                                             |
|o13 : Complex                                                                |
|-----------------------------------------------------------------------------|
| 1                                                                           |
|S                                                                            |
|                                                                             |
|3                                                                            |
+-----------------------------------------------------------------------------+
|i14 : concentration C6                                                       |
|                                                                             |
|o14 = (0, 3)                                                                 |
|                                                                             |
|o14 : Sequence                                                               |
+-----------------------------------------------------------------------------+
|i15 : length C6                                                              |
|                                                                             |
|o15 = 2                                                                      |
+-----------------------------------------------------------------------------+
|i16 : prune C6                                                               |
|                                                                             |
|       1      2      1                                                       |
|o16 = S  <-- S  <-- S                                                        |
|                                                                             |
|      1      2      3                                                        |
|                                                                             |
|o16 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i17 : concentration prune C6                                                 |
|                                                                             |
|o17 = (1, 3)                                                                 |
|                                                                             |
|o17 : Sequence                                                               |
+-----------------------------------------------------------------------------+

See also
========

  * prune(Complex) -- minimal
    presentation of all terms in a complex
  * concentration(Complex) -- indices on which a complex
    may be non-zero

Ways to use this method:
========================

  * length(Complex) -- length of a complex

liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap) -- lift a map of chain complexes along a quasi-isomorphism
**************************************************************************************************************

Synopsis
========

  * Function: liftMapAlongQuasiIsomorphism,
  * Usage:
        f' = liftMapAlongQuasiIsomorphism(f, g)
        f' = f // g
  * Inputs:
      * f, a map of complexes, where each term in the source
        of $f$ is a free module
      * g, a map of complexes, a quasi-isomorphism having
        the same target as $f$
  * Outputs:
      * f', a map of complexes, a map from the source of $f$
        to the source of $g$
  * Consequences:
      * the homotopy relating $f$ and $g \circ f'$ is available as homotopyMap
        f'.

Description
===========

Let $f \colon P \to C$ be a morphism of chain complexes, where each term in $P$
is a free module. Given a quasi-isomorphism $g \colon B \to C$, this method
produces a morphism $f' \colon P \to B$ such that there exists a map $h \colon
P \to C$ of chain complexes having degree $1$ satisfying

$f - g \circ f' = h \circ \operatorname{dd}^P + \operatorname{dd}^C \circ h$.

Given a morphism between complexes, we can construct the corresponding map
between their free resolutions using this method.

To be more precise, given a morphism $\phi \colon B \to C$ of complexes, let
$\alpha \colon P \to B$ and $\beta \colon F \to C$ denote the free resolutions
of the source and target complexes. Lifting the composite map $\phi \circ
\alpha$ along the quasi-isomorphism $\beta$ gives a commutative diagram
$\phantom{WWWW} \begin{array}{ccc} P & \!\!\rightarrow\!\! & F \\ \downarrow \,
{\scriptstyle \alpha} & & \downarrow \, {\scriptstyle \beta} \\ B &
\xrightarrow{\phi} & C \end{array} $

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c,d];                                                    |
+-----------------------------------------------------------------------------+
|i2 : J = ideal(a*b, a*d, b*c);                                               |
|                                                                             |
|o2 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i3 : I = J + ideal(c^3);                                                     |
|                                                                             |
|o3 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i4 : C = prune Hom(S^{2} ** freeResolution I, S^1/I)                         |
|                                                                             |
|o4 = cokernel {-4} | ad bc ab c3 | <-- cokernel {-1} | 0  0  0  0  0  0  0   |
|                                                {-1} | 0  0  0  0  0  0  0   |
|     -3                                         {-2} | 0  0  0  ad bc ab 0   |
|                                                {-3} | ad bc ab 0  0  0  c3  |
|                                                                             |
|                                       -2                                    |
|                                                                             |
|o4 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|ad bc ab 0  0  0  0  c3 0  | <-- cokernel {0}  | 0  0  0  ad bc ab 0  0  0   |
|0  0  0  ad bc ab 0  0  c3 |              {0}  | 0  0  0  0  0  0  ad bc ab  |
|0  0  0  0  0  0  c3 0  0  |              {0}  | 0  0  0  0  0  0  0  0  0   |
|0  0  0  0  0  0  0  0  0  |              {-1} | ad bc ab 0  0  0  0  0  0   |
|                                                                             |
|                                 -1                                          |
|-----------------------------------------------------------------------------|
|0  0  0  0  c3 0  0  | <-- cokernel {2} | ad bc ab c3 |                      |
|0  0  0  0  0  c3 0  |                                                       |
|ad bc ab 0  0  0  c3 |     0                                                 |
|0  0  0  c3 0  0  0  |                                                       |
+-----------------------------------------------------------------------------+
|i5 : D = prune Hom(freeResolution J, S^1/J)                                  |
|                                                                             |
|o5 = cokernel {-3} | ad bc ab 0  0  0  | <-- cokernel {-2} | ad bc ab 0  0   |
|              {-3} | 0  0  0  ad bc ab |              {-2} | 0  0  0  ad bc  |
|                                                      {-2} | 0  0  0  0  0   |
|     -2                                                                      |
|                                             -1                              |
|                                                                             |
|o5 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|0  0  0  0  | <-- cokernel | ad bc ab |                                      |
|ab 0  0  0  |                                                                |
|0  ad bc ab |     0                                                          |
+-----------------------------------------------------------------------------+
|i6 : r = randomComplexMap(D,                                                 |
|                                                                             |
|o6 = -3 : 0 <----- cokernel                                                  |
|               0                                                             |
|                                                                             |
|     -2 : cokernel {-3} | ad                                                 |
|                   {-3} | 0                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|     -1 : cokernel {-2} | ad                                                 |
|                   {-2} | 0                                                  |
|                   {-2} | 0                                                  |
|                                                                             |
|                                                                             |
|     0 : cokernel | ad bc ab                                                 |
|                                                                             |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|C,Cycle=>true)                                                               |
|                                                                             |
|{-4} | ad bc ab c3 | : -3                                                    |
|                                                                             |
|                                                                             |
| bc ab 0  0  0  | <----------------------------------------- cokernel {-1} | |
| 0  0  ad bc ab |    {-3} | 24b2-36bd  0          0    0 |            {-1} | |
|                     {-3} | -30b2-29bd -29b2+43bd -47b 0 |            {-2} | |
|                                                                      {-3} | |
|                                                                             |
| bc ab 0  0  0  0  0  0  | <-------------------------------------------------|
| 0  0  ad bc ab 0  0  0  |    {-2} | 10b2+43bd 21b2       34b2       0    |  |
| 0  0  0  0  0  ad bc ab |    {-2} | 19b2+19bd -10b2-29bd -8b2-22bd  19b  |  |
|                              {-2} | 39bd      21bd       -29b2-24bd -47b |  |
|                                                                             |
| | <------------------ cokernel {2} | ad bc ab c3 | : 0                      |
|      | -38b2-16bd |                                                         |
|-----------------------------------------------------------------------------|
|0  0  0  0  0  0  0  ad bc ab 0  0  0  0  c3 0  | : -2                       |
|0  0  0  0  0  0  0  0  0  0  ad bc ab 0  0  c3 |                            |
|0  0  0  ad bc ab 0  0  0  0  0  0  0  c3 0  0  |                            |
|ad bc ab 0  0  0  c3 0  0  0  0  0  0  0  0  0  |                            |
|                                                                             |
| cokernel {0}  | 0  0  0  ad bc ab 0  0  0  0  0  0  0  c3 0  0  | : -1      |
|          {0}  | 0  0  0  0  0  0  ad bc ab 0  0  0  0  0  c3 0  |           |
|          {0}  | 0  0  0  0  0  0  0  0  0  ad bc ab 0  0  0  c3 |           |
|          {-1} | ad bc ab 0  0  0  0  0  0  0  0  0  c3 0  0  0  |           |
+-----------------------------------------------------------------------------+
|i7 : f = r * resolutionMap C                                                 |
|                                                                             |
|                                                                             |
|o7 = -2 : cokernel {-3} | ad                                                 |
|                   {-3} | 0                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|     -1 : cokernel {-2} | ad                                                 |
|                   {-2} | 0                                                  |
|                   {-2} | 0                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|     0 : cokernel | ad bc ab                                                 |
|                                                                             |
|                                                                             |
|o7 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                                                   8         |
|bc ab 0  0  0  | <----------------------------------------------- S  : -2    |
|0  0  ad bc ab |    {-3} | 0 0 0   0 0 0 24b2-36bd  0         |              |
|                    {-3} | 0 0 47b 0 0 0 -30b2-29bd 29b2-43bd |              |
|                                                                             |
|                                                                             |
|bc ab 0  0  0  0  0  0  | <--------------------------------------------------|
|0  0  ad bc ab 0  0  0  |    {-2} | 0 0 0 0 0 0    0 0 0 -10b2-43bd 21b2     |
|0  0  0  0  0  ad bc ab |    {-2} | 0 0 0 0 0 -19b 0 0 0 -19b2-19bd -10b2-29b|
|                             {-2} | 0 0 0 0 0 47b  0 0 0 -39bd      21bd     |
|                                                                             |
|                                                                             |
|| <--------------------------------------------------------------------------|
|     | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 38b2+16bd 0 0 0 0 0 |
|-----------------------------------------------------------------------------|
|                                                                  24         |
|---------------------------------------------------------------- S   : -1    |
|  -34b2     0 0 0 0 0 0 -21b3      -10b3+24b2d       0 0 0 0 |               |
|d 8b2+22bd  0 0 0 0 0 0 10b3+29b2d -19b3-11b2d+22bd2 0 0 0 0 |               |
|  29b2+24bd 0 0 0 0 0 0 -21b2d     -10b2d+24bd2      0 0 0 0 |               |
|                                                                             |
|           34                                                                |
|--------- S   : 0                                                            |
|0 0 0 |                                                                      |
+-----------------------------------------------------------------------------+
|i8 : g = resolutionMap D                                                     |
|                                                                             |
|                                                                             |
|o8 = -2 : cokernel {-3} | ad                                                 |
|                   {-3} | 0                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|     -1 : cokernel {-2} | ad                                                 |
|                   {-2} | 0                                                  |
|                   {-2} | 0                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|     0 : cokernel | ad bc ab                                                 |
|                                                                             |
|                                                                             |
|o8 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                      2                                      |
|bc ab 0  0  0  | <------------------ S  : -2                                 |
|0  0  ad bc ab |    {-3} | -1 0  |                                           |
|                    {-3} | 0  -1 |                                           |
|                                                                             |
|                                                                   9         |
|bc ab 0  0  0  0  0  0  | <-------------------------------------- S  : -1    |
|0  0  ad bc ab 0  0  0  |    {-2} | 1 0  0  0  -a 0  -b 0  0  |              |
|0  0  0  0  0  ad bc ab |    {-2} | 0 -1 0  -d -c -b 0  0  0  |              |
|                             {-2} | 0 0  -1 0  0  0  -d -c -a |              |
|                                                                             |
|                                         14                                  |
|| <------------------------------------ S   : 0                              |
|     | 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 |                                        |
+-----------------------------------------------------------------------------+
|i9 : assert isQuasiIsomorphism g                                             |
+-----------------------------------------------------------------------------+
|i10 : f' = liftMapAlongQuasiIsomorphism(f, g)                                |
|                                                                             |
|                     1                                                       |
|o10 = -3 : 0 <----- S  : -3                                                  |
|                0                                                            |
|                                                                             |
|            2                                                     8          |
|      -2 : S  <------------------------------------------------- S  : -2     |
|                 {-3} | 0 0 0    0 0 0 -24b2+36bd 0          |               |
|                 {-3} | 0 0 -47b 0 0 0 30b2+29bd  -29b2+43bd |               |
|                                                                             |
|            9                                                                |
|      -1 : S  <--------------------------------------------------------------|
|                 {-2} | 0 0 0 0 0 0    0     0 0 -24b2+36bd          0       |
|                 {-2} | 0 0 0 0 0 0    0     0 0 0                   -24b2+36|
|                 {-2} | 0 0 0 0 0 -47b -47ad 0 0 30bc-48bd+29cd+22d2 30ab-47c|
|                 {-1} | 0 0 0 0 0 0    0     0 0 19b                 -7b     |
|                 {-1} | 0 0 0 0 0 0    0     0 0 0                   0       |
|                 {-1} | 0 0 0 0 0 19   0     0 0 19b                 34b     |
|                 {-1} | 0 0 0 0 0 0    0     0 0 -14b-22d            -21b    |
|                 {-1} | 0 0 0 0 0 0    0     0 0 -30b-29d            47c     |
|                 {-1} | 0 0 0 0 0 0    47d   0 0 0                   -30b-29d|
|                                                                             |
|           14                                                                |
|      0 : S   <--------------------------------------------------------------|
|                 | 0 0 0    0 0 0 0 0 0 0 0 0          -24bd+36d2     0      |
|                 | 0 0 0    0 0 0 0 0 0 0 0 0          0              0      |
|                 | 0 0 0    0 0 0 0 0 0 0 0 0          -24b2+36bd     0      |
|                 | 0 0 0    0 0 0 0 0 0 0 0 0          -24bd+36d2     0      |
|                 | 0 0 0    0 0 0 0 0 0 0 0 24ab-29ad  19ad           -22ad  |
|                 | 0 0 0    0 0 0 0 0 0 0 0 0          0              0      |
|                 | 0 0 19d  0 0 0 0 0 0 0 0 -10bd-29d2 19bd+19d2      -8bd-22|
|                 | 0 0 0    0 0 0 0 0 0 0 0 21bd       -14bd-22d2     34bd   |
|                 | 0 0 0    0 0 0 0 0 0 0 0 0          0              0      |
|                 | 0 0 0    0 0 0 0 0 0 0 0 0          -30ad          0      |
|                 | 0 0 -47b 0 0 0 0 0 0 0 0 0          30bc+29bd-43d2 -29b2+4|
|                 | 0 0 0    0 0 0 0 0 0 0 0 -47cd      -29d2          0      |
|                 | 0 0 0    0 0 0 0 0 0 0 0 0          0              0      |
|                 | 0 0 0    0 0 0 0 0 0 0 0 0          0              0      |
|                                                                             |
|           9                                                                 |
|      1 : S  <---------------------------------------------------------------|
|                {1} | 0 0 0 0 -24b2     0     -29ab      11ab-22ad      0 0 0|
|                {1} | 0 0 0 0 0         0     0          0              0 0 0|
|                {1} | 0 0 0 0 0         19cd  -10b2-29bd 19b2+11bd-22d2 0 0 -|
|                {1} | 0 0 0 0 0         0     21b2       10b2-24bd      0 0 0|
|                {1} | 0 0 0 0 30bc-29cd 47c2  -21bc      -10bc+24cd     0 0 -|
|                {1} | 0 0 0 0 29d2      -47cd 21bd       10bd-24d2      0 0 4|
|                {2} | 0 0 0 0 0         0     0          0              0 0 0|
|                {2} | 0 0 0 0 0         0     0          0              0 0 0|
|                {2} | 0 0 0 0 0         0     0          0              0 0 0|
|                                                                             |
|           2                                                             8   |
|      2 : S  <--------------------------------------------------------- S  : |
|                {3} | 0 -38b2-16bd 0          0 0 0 0 -38bc3-16c3d  |        |
|                {3} | 0 0          -38b2-16bd 0 0 0 0 38bc2d+16c2d2 |        |
|                                                                             |
|                    1                                                        |
|      3 : 0 <----- S  : 3                                                    |
|               0                                                             |
|                                                                             |
|o10 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|       0          0 0 0 0            0            0 0     0         0 0 0    |
|bd     0          0 0 0 24b2d-36bd2  0            0 0     0         0 0 0    |
|2+29ad -29b2+43bd 0 0 0 -30abd-29ad2 -29abd+43ad2 0 0     0         0 0 -29bc|
|       -22b       0 0 0 -24b2+36bd   0            0 -29b2 11b2-22bd 0 0 0    |
|       0          0 0 0 0            0            0 0     0         0 0 0    |
|       -8b        0 0 0 0            0            0 -10b2 19b2      0 0 0    |
|       34b        0 0 0 0            0            0 21b2  10b2-24bd 0 0 0    |
|       0          0 0 0 0            0            0 0     0         0 0 29bc2|
|       0          0 0 0 30bd+29d2    29bd-43d2    0 0     0         0 0 0    |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|    -24b2+36bd           0 0     0     0          0              0         0 |
|    0                    0 0     0     0          0              0         0 |
|    7b2                  0 0     -29b2 0          0              11b2-22bd 0 |
|    7bd                  0 0     -29bd 0          0              11bd-22d2 0 |
|    19ab                 0 24b2  0     -29ab      11ab-22ad      0         0 |
|    -34b2+19c2           0 19cd  -10b2 0          0              19b2      0 |
|d2  19b2+19bd            0 0     0     -10b2-29bd 19b2+11bd-22d2 0         0 |
|    -14b2-22bd           0 0     0     21b2       10b2-24bd      0         0 |
|    21b2                 0 0     21b2  0          0              10b2-24bd 0 |
|    -30ab-47c2-29ad+21bd 0 -47cd 21bd  0          0              10bd-24d2 0 |
|3bd 29b2+29bc-43bd       0 0     0     0          0              0         0 |
|    0                    0 0     0     0          0              0         0 |
|    30bc                 0 0     0     0          0              0         0 |
|    0                    0 0     0     0          0              0         0 |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|      0          0          0          0 0 0 -22acd      0            0      |
|      0          0          0          0 0 0 0           0            0      |
|19c2d 0          0          0          0 0 0 -8bcd-22cd2 0            0      |
|      0          0          0          0 0 0 34bcd       0            0      |
|47c3  0          0          0          0 0 0 24c2d       0            29bc3  |
|7c2d  0          0          0          0 0 0 -24cd2      0            -29bc2d|
|      -38b2-16bd 0          0          0 0 0 0           0            0      |
|      0          -38b2-16bd 0          0 0 0 0           -38bc2-16c2d 0      |
|      0          0          -38b2-16bd 0 0 0 0           0            0      |
|                                                                             |
|                                                                             |
|2                                                                            |
|-----------------------------------------------------------------------------|
|                            24                                               |
|-------------------------- S   : -1                                          |
|        0              |                                                     |
|        0              |                                                     |
|3+43c3d -29bc2d+43c2d2 |                                                     |
|        0              |                                                     |
|        0              |                                                     |
|        0              |                                                     |
|        0              |                                                     |
|-43c2d  29bcd-43cd2    |                                                     |
|        0              |                                                     |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|0 0 0 0          0 0 0            0 0            0      0              0     |
|0 0 0 0          0 0 0            0 0            0      0              0     |
|0 0 0 0          0 0 -22bc2       0 -22bcd       0      0              0     |
|0 0 0 0          0 0 -22c2d       0 -22cd2       0      0              0     |
|0 0 0 0          0 0 0            0 0            0      0              0     |
|0 0 0 0          0 0 -8bc2        0 -8bcd        0      0              0     |
|0 0 0 0          0 0 0            0 0            0      0              0     |
|0 0 0 0          0 0 0            0 0            0      0              0     |
|0 0 0 0          0 0 34bc2        0 34bcd        0      0              0     |
|0 0 0 0          0 0 -29bc2-24c2d 0 -29bcd-24cd2 29acd  0              0     |
|0 0 0 0          0 0 0            0 0            -29bc2 0              0     |
|0 0 0 0          0 0 0            0 0            -43cd2 -29bc2d+43c2d2 -29bcd|
|0 0 0 0          0 0 0            0 0            0      0              0     |
|0 0 0 -38b2-16bd 0 0 0            0 0            0      0              0     |
|                                                                             |
|                                      24                                     |
|------------------------------------ S   : 1                                 |
| 22ac2d        0 0       0       |                                           |
| 0             0 0       0       |                                           |
| 8bc2d+22c2d2  0 0       0       |                                           |
| -34bc2d       0 0       0       |                                           |
| -29bc3-24c3d  0 29bc2d  29ac2d  |                                           |
| 29bc2d+24c2d2 0 -29bcd2 -29acd2 |                                           |
| 0             0 0       0       |                                           |
| 0             0 0       0       |                                           |
| 0             0 0       0       |                                           |
|-----------------------------------------------------------------------------|
|             34                                                              |
|----------- S   : 0                                                          |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|        |                                                                    |
|2+43cd3 |                                                                    |
|        |                                                                    |
|        |                                                                    |
+-----------------------------------------------------------------------------+
|i11 : assert(f' == f//g)                                                     |
+-----------------------------------------------------------------------------+
|i12 : assert isWellDefined f'                                                |
+-----------------------------------------------------------------------------+
|i13 : assert isComplexMorphism f'                                            |
+-----------------------------------------------------------------------------+
|i14 : h = homotopyMap f'                                                     |
|                                                                             |
|                                                       1                     |
|o14 = -2 : cokernel {-3} | ad bc ab 0  0  0  | <----- S  : -3                |
|                    {-3} | 0  0  0  ad bc ab |    0                          |
|                                                                             |
|                                                                8            |
|      -1 : cokernel {-2} | ad bc ab 0  0  0  0  0  0  | <----- S  : -2       |
|                    {-2} | 0  0  0  ad bc ab 0  0  0  |    0                 |
|                    {-2} | 0  0  0  0  0  0  ad bc ab |                      |
|                                                                             |
|                                        24                                   |
|      0 : cokernel | ad bc ab | <----- S   : -1                              |
|                                   0                                         |
|                                                                             |
|                    34                                                       |
|      1 : 0 <----- S   : 0                                                   |
|               0                                                             |
|                                                                             |
|                    24                                                       |
|      2 : 0 <----- S   : 1                                                   |
|               0                                                             |
|                                                                             |
|                    8                                                        |
|      3 : 0 <----- S  : 2                                                    |
|               0                                                             |
|                                                                             |
|                    1                                                        |
|      4 : 0 <----- S  : 3                                                    |
|               0                                                             |
|                                                                             |
|o14 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i15 : isNullHomotopyOf(h, g * (f//g) - f)                                    |
|                                                                             |
|o15 = true                                                                   |
+-----------------------------------------------------------------------------+

TODO: XXX start here. Do triangles, invert interesting quasi-isomorphism.
isSemiFree, and add in an example or 2.  Include finding an inverse for a
quasi-isomorphism. We need some kind of better example here.

Caveat
======

The following three assumptions are not checked: $f$ is a morphism, the source
of $f$ is semifree, and $g$ is a quasi-isomorphism.

See also
========

  * Towards computing in the derived category
  * isQuasiIsomorphism -- whether a
    map of complexes is a quasi-isomorphism
  * isComplexMorphism -- whether a
    complex map is a morphism of complexes

Ways to use this method:
========================

  * liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap)
    -- lift a map of
    chain complexes along a quasi-isomorphism

longExactSequence(ComplexMap,ComplexMap) -- make the long exact sequence in homology
************************************************************************************

Synopsis
========

  * Function: longExactSequence,
  * Usage:
        L = longExactSequence(g, f)
  * Inputs:
      * f, a map of complexes,
      * g, a map of complexes,
  * Optional inputs (Macaulay2Doc),:
      * Concentration => a sequence (Macaulay2Doc), default
        value null, this optional argument is not yet implemented
  * Outputs:
      * L, a complex,

Description
===========

Every short exact sequence of complexes

$\phantom{WWWW} 0 \leftarrow C \xleftarrow{g} B  \xleftarrow{f} A \leftarrow 0
$

gives rise to a long exact sequence $L$ in homology having the form

$\phantom{WWWW} \dotsb \leftarrow H_{i-1}(C) \xleftarrow{H_{i-1}(g)} H_{i-1}(B)
\xleftarrow{H_{i-1}(f)} H_{i-1}(A) \xleftarrow{\delta_i} H_{i}(C)
\xleftarrow{H_{i}(g)} H_{i}(B) \xleftarrow{H_{i}(f)} H_{i}(A) \leftarrow
\dotsb. $

This method returns the complex $L$ such that, for all integers $i$, we have
$L_{3i} = H_i(C)$, $L_{3i+1} = H_i(B)$, and $L_{3i+2} = H_i(A)$. The
differentials $\operatorname{dd}^L_{3i}$ are the connecting homomorphisms
$\delta_i \colon H_i(C) \to H_{i-1}(A)$.  Moreover, we have
$\operatorname{dd}^L_{3i+1} = H_{i}(g)$ and $\operatorname{dd}^L_{3i+2} =
H_{i}(f)$.

For example, consider a free resolution $F$ of $S/I$. Applying the Hom functor
$\operatorname{Hom}(F, -)$ to a short exact sequence of modules

$\phantom{WWWW} 0 \leftarrow S/h \leftarrow S \xleftarrow{h} S(- \deg h)
\leftarrow 0 $

gives rise to a short exact sequence of complexes.  The corresponding long
exact sequence $L$ in homology has the form

$\phantom{WWWW} \dotsb \leftarrow \operatorname{Ext}^{d+1}(S/I, S(-\deg h))
\xleftarrow{\delta} \operatorname{Ext}^d(S/I, S/h) \leftarrow
\operatorname{Ext}^d(S/I, S) \leftarrow \operatorname{Ext}^d(S/I, S(-\deg h))
\leftarrow \dotsb. $

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..d, Degrees=>{2:{1,0},2:{0,1}}];                           |
+-----------------------------------------------------------------------------+
|i2 : h = a*c^2 + a*c*d + b*d^2;                                              |
+-----------------------------------------------------------------------------+
|i3 : I = (ideal(a,b) * ideal(c,d))^[2]                                       |
|                                                                             |
|             2 2   2 2   2 2   2 2                                           |
|o3 = ideal (a c , a d , b c , b d )                                          |
|                                                                             |
|o3 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i4 : F = freeResolution comodule I;                                          |
+-----------------------------------------------------------------------------+
|i5 : g = Hom(F, map(S^1/h, S^1, 1))                                          |
|                                                                             |
|                                                                 1           |
|o5 = -3 : cokernel {-4, -4} | ac2+acd+bd2 | <------------------ S  : -3      |
|                                               {-4, -4} | 1 |                |
|                                                                             |
|                                                                             |
|     -2 : cokernel {-4, -2} | ac2+acd+bd2 0           0           0          |
|                   {-4, -2} | 0           ac2+acd+bd2 0           0          |
|                   {-2, -4} | 0           0           ac2+acd+bd2 0          |
|                   {-2, -4} | 0           0           0           ac2+acd+bd2|
|                                                                             |
|                                                                             |
|                                                                             |
|     -1 : cokernel {-2, -2} | ac2+acd+bd2 0           0           0          |
|                   {-2, -2} | 0           ac2+acd+bd2 0           0          |
|                   {-2, -2} | 0           0           ac2+acd+bd2 0          |
|                   {-2, -2} | 0           0           0           ac2+acd+bd2|
|                                                                             |
|                                                                             |
|                                              1                              |
|     0 : cokernel | ac2+acd+bd2 | <--------- S  : 0                          |
|                                     | 1 |                                   |
|                                                                             |
|o5 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                             4                                               |
|| <------------------------ S  : -2                                          |
||    {-4, -2} | 1 0 0 0 |                                                    |
||    {-4, -2} | 0 1 0 0 |                                                    |
||    {-2, -4} | 0 0 1 0 |                                                    |
|     {-2, -4} | 0 0 0 1 |                                                    |
|                                                                             |
|                             4                                               |
|| <------------------------ S  : -1                                          |
||    {-2, -2} | 1 0 0 0 |                                                    |
||    {-2, -2} | 0 1 0 0 |                                                    |
||    {-2, -2} | 0 0 1 0 |                                                    |
|     {-2, -2} | 0 0 0 1 |                                                    |
+-----------------------------------------------------------------------------+
|i6 : f = Hom(F, map(S^1, S^{-degree h}, {{h}}))                              |
|                                                                             |
|           1                                1                                |
|o6 = -3 : S  <---------------------------- S  : -3                           |
|                {-4, -4} | ac2+acd+bd2 |                                     |
|                                                                             |
|           4                                                                 |
|     -2 : S  <---------------------------------------------------------------|
|                {-4, -2} | ac2+acd+bd2 0           0           0           | |
|                {-4, -2} | 0           ac2+acd+bd2 0           0           | |
|                {-2, -4} | 0           0           ac2+acd+bd2 0           | |
|                {-2, -4} | 0           0           0           ac2+acd+bd2 | |
|                                                                             |
|           4                                                                 |
|     -1 : S  <---------------------------------------------------------------|
|                {-2, -2} | ac2+acd+bd2 0           0           0           | |
|                {-2, -2} | 0           ac2+acd+bd2 0           0           | |
|                {-2, -2} | 0           0           ac2+acd+bd2 0           | |
|                {-2, -2} | 0           0           0           ac2+acd+bd2 | |
|                                                                             |
|          1                       1                                          |
|     0 : S  <------------------- S  : 0                                      |
|               | ac2+acd+bd2 |                                               |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|   4                                                                         |
|- S  : -2                                                                    |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|   4                                                                         |
|- S  : -1                                                                    |
+-----------------------------------------------------------------------------+
|i7 : assert isWellDefined g                                                  |
+-----------------------------------------------------------------------------+
|i8 : assert isWellDefined f                                                  |
+-----------------------------------------------------------------------------+
|i9 : assert isShortExactSequence(g, f)                                       |
+-----------------------------------------------------------------------------+
|i10 : L = longExactSequence(g,f)                                             |
|                                                                             |
|o10 = cokernel {-4, -4} | d2 -c2 -b2 a2 ac2+acd+bd2 | <-- cokernel {-4, -4} ||
|                                                                             |
|      -9                                                  -8                 |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o10 : Complex                                                                |
|-----------------------------------------------------------------------------|
|d2 -c2 -b2 a2 | <-- cokernel {-3, -2} | d2 -c2 -b2 a2 | <-- subquotient ({-4,|
|                                                                         {-4,|
|                    -7                                                   {-2,|
|                                                                         {-2,|
|                                                                             |
|                                                            -6               |
|-----------------------------------------------------------------------------|
|-2} | c2 ac+bd -bc   b2 0   a2  0  ab    0  0           |, {-4, -2} | -b2 a2 |
|-2} | d2 -ad   ac+ad 0  b2  0   a2 0     0  0           |  {-4, -2} | 0   0  |
|-4} | 0  0     0     d2 -c2 0   0  0     a2 ac2+acd+bd2 |  {-2, -4} | -d2 0  |
|-4} | 0  0     0     0  0   -d2 c2 c2+cd b2 0           |  {-2, -4} | 0   -d2|
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|0   0  ac2+acd+bd2 0           0           0           |) <-- subquotient    |
|-b2 a2 0           ac2+acd+bd2 0           0           |                     |
|c2  0  0           0           ac2+acd+bd2 0           |                     |
|0   c2 0           0           0           ac2+acd+bd2 |                     |
|                                                                             |
|                                                              -5             |
|-----------------------------------------------------------------------------|
|({-4, -2} | c2 b2 0   a2  0  0  |, {-4, -2} | -b2 a2  0   0  |) <--          |
| {-4, -2} | d2 0  b2  0   a2 0  |  {-4, -2} | 0   0   -b2 a2 |               |
| {-2, -4} | 0  d2 -c2 0   0  a2 |  {-2, -4} | -d2 0   c2  0  |               |
| {-2, -4} | 0  0  0   -d2 c2 b2 |  {-2, -4} | 0   -d2 0   c2 |               |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|subquotient ({-3, 0}  | c2 b2 0   a2  0  0  |, {-3, 0}  | -b2 a2  0   0  |)  |
|             {-3, 0}  | d2 0  b2  0   a2 0  |  {-3, 0}  | 0   0   -b2 a2 |   |
|             {-1, -2} | 0  d2 -c2 0   0  a2 |  {-1, -2} | -d2 0   c2  0  |   |
|             {-1, -2} | 0  0  0   -d2 c2 b2 |  {-1, -2} | 0   -d2 0   c2 |   |
|                                                                             |
|-4                                                                           |
|-----------------------------------------------------------------------------|
|<-- subquotient ({-2, -2} | ac2+acd+bd2 0           0           0            |
|                 {-2, -2} | 0           ac2+acd+bd2 0           0            |
|                 {-2, -2} | 0           0           ac2+acd+bd2 0            |
|                 {-2, -2} | 0           0           0           ac2+acd+bd2  |
|                                                                             |
|    -3                                                                       |
|-----------------------------------------------------------------------------|
|-a2cd-abd2 a3c+a2bd -a2bc     acd3+bd4   c2d4            |, {-2, -2} |       |
|b2c2       ab2c+b3d -b3c      bc4+bc3d   c6+2c5d+c4d2    |  {-2, -2} |       |
|a2d2       -a3d     a3c+a3d   -ad4       d6              |  {-2, -2} |       |
|b2d2       -ab2d    ab2c+ab2d bc2d2+bcd3 c4d2+2c3d3+c2d4 |  {-2, -2} |       |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|-a2cd-abd2 ac2+acd+bd2 0           0           0           |) <-- subquotient|
|b2c2       0           ac2+acd+bd2 0           0           |                 |
|a2d2       0           0           ac2+acd+bd2 0           |                 |
|b2d2       0           0           0           ac2+acd+bd2 |                 |
|                                                                             |
|                                                                  -2         |
|-----------------------------------------------------------------------------|
|({-2, -2} | a2c2 |, {-2, -2} | a2c2 |) <-- subquotient ({-1, 0} | a2c2 |,    |
| {-2, -2} | b2c2 |  {-2, -2} | b2c2 |                   {-1, 0} | b2c2 |     |
| {-2, -2} | a2d2 |  {-2, -2} | a2d2 |                   {-1, 0} | a2d2 |     |
| {-2, -2} | b2d2 |  {-2, -2} | b2d2 |                   {-1, 0} | b2d2 |     |
|                                                                             |
|                                           -1                                |
|-----------------------------------------------------------------------------|
|{-1, 0} | a2c2 |) <-- subquotient (| ac2+acd+bd2 |, | ac2+acd+bd2 |) <--     |
|{-1, 0} | b2c2 |                                                             |
|{-1, 0} | a2d2 |      0                                                      |
|{-1, 0} | b2d2 |                                                             |
|-----------------------------------------------------------------------------|
|image 0 <-- image 0 <-- 0                                                    |
|                                                                             |
|1           2           3                                                    |
+-----------------------------------------------------------------------------+
|i11 : assert isWellDefined L                                                 |
+-----------------------------------------------------------------------------+
|i12 : assert(HH L == 0)                                                      |
+-----------------------------------------------------------------------------+

We verify that the indexing on $L$ in this example matches the description
above.

+----------------------------------+
|i13 : delta = connectingMap(g, f);|
+----------------------------------+
|i14 : assert(dd^L_-9 === delta_-3)|
+----------------------------------+
|i15 : assert(dd^L_-8 === HH_-3 g) |
+----------------------------------+
|i16 : assert(dd^L_-7 === HH_-3 f) |
+----------------------------------+
|i17 : assert(dd^L_-6 === delta_-2)|
+----------------------------------+
|i18 : assert(dd^L_-5 === HH_-2 g) |
+----------------------------------+
|i19 : assert(dd^L_-4 === HH_-2 f) |
+----------------------------------+
|i20 : assert(dd^L_-3 === delta_-1)|
+----------------------------------+

See also
========

  * Towards computing in the derived category
  * connectingMap, --
    construct the connecting homomorphism on homology
  * isShortExactSequence -- whether a
    chain complex is a short exact sequence
  * homology (Macaulay2Doc) -- general homology functor

Ways to use this method:
========================

  * longExactSequence(ComplexMap,ComplexMap)
    -- make the long exact
    sequence in homology

Making chain complexes -- information about the basic constructors
******************************************************************

Basic constructors
==================

  * complex(HashTable) -- make a chain complex
  * complex(List) -- make a chain complex
  * complex(Module) -- make a chain complex of
    length zero
  * complex(Complex) -- make a complex by
    reindexing the terms of the complex
  * Complex Array -- shift a complex or complex map
  * isWellDefined(Complex) -- whether a
    complex is well-defined

Important computations creating new complexes
=============================================

  * freeResolution(Module) -- compute a free resolution
    of a module or ideal
  * resolution(Complex) -- minimal free
    resolution of a complex
  * HH Complex -- homology of a complex

More advanced constructors
==========================

  * Complex ++ Complex -- direct sum of
    complexes
  * Complex ** Complex -- tensor product of
    complexes
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes
  * dual(Complex) -- make the dual of a complex
  * RingMap Complex -- apply a ring map
  * RingMap ** Complex -- tensor a complex along
    a ring map
  * koszulComplex(Matrix) -- makes the Koszul
    complex
  * naiveTruncation(Complex,ZZ,ZZ)
    -- drops all terms of a complex
    outside a given interval
  * canonicalTruncation(Complex,ZZ,ZZ)
    -- reducing the number of
    non-zero terms of a complex
  * minimalPresentation(Complex), --
    minimal presentation of all terms in a complex
  * minimize(Complex) -- a quasi-isomorphic
    complex whose terms have minimal rank
  * gradedModule(Complex) -- a new complex in
    which the differential is zero
  * part(List,Complex) -- extract a graded
    component of a complex
  * truncate(List,Complex) -- truncation
    of a complex at a specified degree or set of degrees
  * yonedaExtension(Matrix) -- creates a
    chain complex representing an extension of modules

Extracting complexes from complex maps
======================================

  * source(ComplexMap) -- get the source of a
    map of chain complexes
  * target(ComplexMap) -- get the target of a
    map of chain complexes
  * kernel(ComplexMap) -- make the kernel of a
    map of complexes
  * cokernel(ComplexMap) -- make the cokernel
    of a map of complexes
  * image(ComplexMap) -- make the image of a map
    of complexes
  * coimage(ComplexMap) -- make the coimage of
    a map of complexes
  * cone(ComplexMap) -- make the mapping cone of a
    morphism of chain complexes
  * cylinder(ComplexMap) -- make the mapping cylinder of a
    morphism of chain complexes

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * Basic invariants and properties, --
    information about accessing basic features
  * Working with Ext -- information about functorial
    properties
  * Working with Tor -- information about functorial
    properties
  * Towards computing in the derived category

Making maps between chain complexes -- information about the basic constructors
*******************************************************************************

Basic constructors
==================

  * map(Complex,Complex,HashTable)
    -- make a map of chain complexes
  * map(Complex,Complex,ZZ) -- make the
    zero map or identity between chain complexes
  * map(Complex,Complex,Function),
    -- make a map of chain complexes
  * map(Complex,Complex,List) -- make
    a map of chain complexes
  * map(Complex,Complex,ComplexMap)
    -- make a new map of chain
    complexes from an existing one
  * id _ Complex -- the identity map of a chain complex
  * differential of a chain complex, --
    get the maps between the terms in a complex
  * ComplexMap Array -- shift a complex or complex map
  * isWellDefined(ComplexMap) -- whether
    a map of chain complexes is well-defined

Important computations creating new complex maps
================================================

  * resolutionMap(Complex) -- map from a free resolution
    to the given complex
  * HH ComplexMap -- induced map on homology or
    cohomology
  * augmentationMap(Complex) -- map from a free
    resolution to a module regarded as a complex
  * Complex ** Matrix -- create the tensor
    product of a complex and a map of modules
  * freeResolution(Matrix) -- compute the
    induced map between free resolutions
  * extend(Complex,Complex,Matrix)
    -- extend a map of
    modules to a map of chain complexes
  * nullHomotopy(ComplexMap) -- a map
    which is a candidate for being a null homotopy

Canonical maps between complexes
================================

Some complexes come with canonical maps. To access the complex map, one uses
canonicalMap(Complex,Complex). The following operations
have associated canonical maps.

  * kernel(ComplexMap) -- make the kernel of a
    map of complexes
  * cokernel(ComplexMap) -- make the cokernel
    of a map of complexes
  * image(ComplexMap) -- make the image of a map
    of complexes
  * coimage(ComplexMap) -- make the coimage of
    a map of complexes
  * cone(ComplexMap) -- make the mapping cone of a
    morphism of chain complexes
  * cylinder(ComplexMap) -- make the mapping cylinder of a
    morphism of chain complexes
  * inducedMap(Complex,Complex), --
    make the map of complexes induced at each term by the identity map

Random maps of chain complexes
==============================

The method randomComplexMap(Complex,Complex),
allows one to construct random complex
maps, random morphisms between complexes, and random null homotopies between
complexes.

  * isCommutative(ComplexMap) -- whether
    a complex map commutes with the differentials
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes
  * isNullHomotopic(ComplexMap), --
    whether a map of complexes is null-homotopic

Elementary operations on complex maps
=====================================

  * arithmetic with complex maps, --
    perform arithmetic operations on complex maps
  * ComplexMap + ComplexMap -- perform
    arithmetic operations on complex maps
  * ComplexMap | ComplexMap -- join or
    concatenate maps horizontally
  * ComplexMap || ComplexMap -- join or
    concatenate maps vertically
  * ComplexMap ++ ComplexMap -- direct sum of
    complex maps
  * ComplexMap ** ComplexMap -- the map of
    complexes between tensor complexes
  * Hom(ComplexMap,ComplexMap) -- the
    map of complexes between Hom complexes
  * dual(ComplexMap) -- the dual of a map of
    complexes
  * ComplexMap _ Array -- the composition with the
    canonical inclusion or projection map
  * ComplexMap ^ Array -- the composition with the
    canonical inclusion or projection map
  * naiveTruncation(ComplexMap,Sequence)
    -- drops all terms in the source
    of a complex outside a given interval
  * canonicalTruncation(ComplexMap,Sequence)
    -- reducing the number of
    non-zero terms of a complex
  * part(List,ComplexMap) -- extract a
    graded component of a map of complexes
  * truncate(List,ComplexMap), --
    truncation of a complex map at a specified degree or set of degrees
  * RingMap ComplexMap -- apply a ring map to a map
    of complexes
  * RingMap ** ComplexMap -- tensor a map of
    complexes along a ring map

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Basic invariants and properties, --
    information about accessing basic features
  * Working with Ext -- information about functorial
    properties
  * Working with Tor -- information about functorial
    properties
  * Towards computing in the derived category

map(Complex,Complex,ComplexMap) -- make a new map of chain complexes from an existing one
*****************************************************************************************

Synopsis
========

  * Function: map (Macaulay2Doc),
  * Usage:
        g = map(D, C, f)
  * Inputs:
      * C, a complex,
      * D, a complex,
      * f, a map of complexes, regarded as providing
        matrices which induce maps between the terms of $C$ and $D$
  * Optional inputs (Macaulay2Doc),:
      * Degree (Macaulay2Doc), => an integer (Macaulay2Doc),
        default value null, the degree $d$ of the resulting
        map
      * DegreeLift (Macaulay2Doc), => ...,
        default value null, unused
      * DegreeMap (Macaulay2Doc), => ...,
        default value null, unused
  * Outputs:
      * g, a map of complexes,

Description
===========

A map of complexes $f : C' \rightarrow D'$ is a sequence of maps $f_i : C'_i
\rightarrow D'_{d'+i}$. The new map $g : C \rightarrow D$ is the sequence of
maps $g_i : C_i \rightarrow D_{d+i}$ induced by the matrix of $f_i$.

One use for this function is to get the new map of chain complexes obtained by
shifting the source or target of an existing chain map.  For example, one can
regard the differential on a complex can be regarded as a map of degree zero
between shifted complexes.

+-----------------------------------------+
|i1 : R = ZZ/101[a,b,c];                  |
+-----------------------------------------+
|i2 : C = freeResolution coker vars R     |
|                                         |
|      1      3      3      1             |
|o2 = R  <-- R  <-- R  <-- R              |
|                                         |
|     0      1      2      3              |
|                                         |
|o2 : Complex                             |
+-----------------------------------------+
|i3 : f = map(C[-1], C, dd^C, Degree => 0)|
|                                         |
|          1                 3            |
|o3 = 1 : R  <------------- R  : 1        |
|               | a b c |                 |
|                                         |
|          3                        3     |
|     2 : R  <-------------------- R  : 2 |
|               {1} | -b -c 0  |          |
|               {1} | a  0  -c |          |
|               {1} | 0  a  b  |          |
|                                         |
|          3                  1           |
|     3 : R  <-------------- R  : 3       |
|               {2} | c  |                |
|               {2} | -b |                |
|               {2} | a  |                |
|                                         |
|o3 : ComplexMap                          |
+-----------------------------------------+
|i4 : assert isWellDefined f              |
+-----------------------------------------+
|i5 : assert(degree f == 0)               |
+-----------------------------------------+
|i6 : assert isCommutative f              |
+-----------------------------------------+
|i7 : assert isComplexMorphism f          |
+-----------------------------------------+
|i8 : assert not isComplexMorphism dd^C   |
+-----------------------------------------+

See also
========

  * ComplexMap -- the class of all maps between chain
    complexes
  * map(Complex,Complex,Function),
    -- make a map of chain complexes
  * isWellDefined(ComplexMap) -- whether
    a map of chain complexes is well-defined
  * degree(ComplexMap) -- get the degree of a
    map of chain complexes
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes
  * isCommutative(ComplexMap) -- whether
    a complex map commutes with the differentials
  * Complex Array -- shift a complex or complex map

Ways to use this method:
========================

  * map(Complex,Complex,ComplexMap)
    -- make a new map of chain
    complexes from an existing one

map(Complex,Complex,Function) -- make a map of chain complexes
**************************************************************

Synopsis
========

  * Function: map (Macaulay2Doc),
  * Usage:
        f = map(D, C, fcn)
  * Inputs:
      * C, a complex,
      * D, a complex,
      * fcn, a function (Macaulay2Doc), whose values at
        integers are the maps between the corresponding terms
  * Optional inputs (Macaulay2Doc),:
      * Degree (Macaulay2Doc), => an integer (Macaulay2Doc),
        default value null, the degree of the resulting map
      * DegreeLift (Macaulay2Doc), => ...,
        default value null, unused
      * DegreeMap (Macaulay2Doc), => ...,
        default value null, unused
  * Outputs:
      * f, a map of complexes,

Description
===========

A map of complexes $f : C \rightarrow D$ of degree $d$ is a sequence of maps
$f_i : C_i \rightarrow D_{d+i}$. No relationship between the maps $f_i$ and and
the differentials of either $C$ or $D$ is assumed.

We construct a map of chain complexes by specifying a function which determines
the maps between the terms.

+-------------------------------------------------+
|i1 : R = ZZ/101[x]/x^3;                          |
+-------------------------------------------------+
|i2 : M = coker vars R                            |
|                                                 |
|o2 = cokernel | x |                              |
|                                                 |
|                            1                    |
|o2 : R-module, quotient of R                     |
+-------------------------------------------------+
|i3 : C = freeResolution(M, LengthLimit => 6)     |
|                                                 |
|      1      1      1      1      1      1      1|
|o3 = R  <-- R  <-- R  <-- R  <-- R  <-- R  <-- R |
|                                                 |
|     0      1      2      3      4      5      6 |
|                                                 |
|o3 : Complex                                     |
+-------------------------------------------------+
|i4 : D = C[1]                                    |
|                                                 |
|      1      1      1      1      1      1      1|
|o4 = R  <-- R  <-- R  <-- R  <-- R  <-- R  <-- R |
|                                                 |
|     -1     0      1      2      3      4      5 |
|                                                 |
|o4 : Complex                                     |
+-------------------------------------------------+
|i5 : f = map(D, C, i ->                          |
|         if odd i then                           |
|             map(D_i, C_i, {{x}})                |
|         else map(D_i, C_i, {{x^2}})             |
|         )                                       |
|                                                 |
|          1                  1                   |
|o5 = 0 : R  <-------------- R  : 0               |
|               {1} | x2 |                        |
|                                                 |
|          1                 1                    |
|     1 : R  <------------- R  : 1                |
|               {3} | x |                         |
|                                                 |
|          1                  1                   |
|     2 : R  <-------------- R  : 2               |
|               {4} | x2 |                        |
|                                                 |
|          1                 1                    |
|     3 : R  <------------- R  : 3                |
|               {6} | x |                         |
|                                                 |
|          1                  1                   |
|     4 : R  <-------------- R  : 4               |
|               {7} | x2 |                        |
|                                                 |
|          1                 1                    |
|     5 : R  <------------- R  : 5                |
|               {9} | x |                         |
|                                                 |
|o5 : ComplexMap                                  |
+-------------------------------------------------+
|i6 : assert isWellDefined f                      |
+-------------------------------------------------+
|i7 : assert isCommutative f                      |
+-------------------------------------------------+
|i8 : assert(source f == C)                       |
+-------------------------------------------------+
|i9 : assert(target f == D)                       |
+-------------------------------------------------+

See also
========

  * ComplexMap -- the class of all maps between chain
    complexes
  * isWellDefined(ComplexMap) -- whether
    a map of chain complexes is well-defined
  * isCommutative(ComplexMap) -- whether
    a complex map commutes with the differentials
  * source(ComplexMap) -- get the source of a
    map of chain complexes
  * target(ComplexMap) -- get the target of a
    map of chain complexes

Ways to use this method:
========================

  * map(Complex,Complex,Function),
    -- make a map of chain complexes

map(Complex,Complex,HashTable) -- make a map of chain complexes
***************************************************************

Synopsis
========

  * Function: map (Macaulay2Doc),
  * Usage:
        f = map(D, C, H)
  * Inputs:
      * C, a complex,
      * D, a complex,
      * H, a hash table (Macaulay2Doc), whose keys are
        integers, and whose values are the maps between the corresponding terms
  * Optional inputs (Macaulay2Doc),:
      * Degree (Macaulay2Doc), => an integer (Macaulay2Doc),
        default value null, the degree of the resulting map
      * DegreeLift (Macaulay2Doc), => ...,
        default value null, unused
      * DegreeMap (Macaulay2Doc), => ...,
        default value null, unused
  * Outputs:
      * f, a map of complexes,

Description
===========

A map of complexes $f : C \rightarrow D$ of degree $d$ is a sequence of maps
$f_i : C_i \rightarrow D_{d+i}$. No relationship between the maps $f_i$ and and
the differentials of either $C$ or $D$ is assumed.

We construct a map of chain complexes by specifying the individual maps between
the terms.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c];                                                      |
+-----------------------------------------------------------------------------+
|i2 : C = freeResolution coker matrix{{a^2-b^2,b^3-c^3,c^4}}                  |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : D = freeResolution coker vars R                                         |
|                                                                             |
|      1      3      3      1                                                 |
|o3 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : H = hashTable { 0 => map(D_0, C_0, 1),                                  |
|         1 => map(D_1, C_1, {{a, 0, 0}, {-b, b^2, 0}, {0, -c^2, c^3}}),      |
|         2 => map(D_2, C_2, {{a*b^2, 0, 0}, {-a*c^2, a*c^3, 0}, {b*c^2,      |
|         3 => map(D_3, C_3, {{a*b^2*c^3}})                                   |
|         }                                                                   |
|                                                                             |
|o4 = HashTable{0 => | 1 |                 }                                  |
|               1 => {1} | a  0   0  |                                        |
|                    {1} | -b b2  0  |                                        |
|                    {1} | 0  -c2 c3 |                                        |
|               2 => {2} | ab2  0    0    |                                   |
|                    {2} | -ac2 ac3  0    |                                   |
|                    {2} | bc2  -bc3 b2c3 |                                   |
|               3 => {3} | ab2c3 |                                            |
|                                                                             |
|o4 : HashTable                                                               |
|-----------------------------------------------------------------------------|
|-b*c^3, b^2*c^3}}),                                                          |
+-----------------------------------------------------------------------------+
|i5 : f = map(D, C, H)                                                        |
|                                                                             |
|          1             1                                                    |
|o5 = 0 : R  <--------- R  : 0                                                |
|               | 1 |                                                         |
|                                                                             |
|          3                         3                                        |
|     1 : R  <--------------------- R  : 1                                    |
|               {1} | a  0   0  |                                             |
|               {1} | -b b2  0  |                                             |
|               {1} | 0  -c2 c3 |                                             |
|                                                                             |
|          3                              3                                   |
|     2 : R  <-------------------------- R  : 2                               |
|               {2} | ab2  0    0    |                                        |
|               {2} | -ac2 ac3  0    |                                        |
|               {2} | bc2  -bc3 b2c3 |                                        |
|                                                                             |
|          1                     1                                            |
|     3 : R  <----------------- R  : 3                                        |
|               {3} | ab2c3 |                                                 |
|                                                                             |
|o5 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i6 : assert isWellDefined f                                                  |
+-----------------------------------------------------------------------------+
|i7 : assert isHomogeneous f                                                  |
+-----------------------------------------------------------------------------+
|i8 : assert(degree f == 0)                                                   |
+-----------------------------------------------------------------------------+
|i9 : assert isComplexMorphism f                                              |
+-----------------------------------------------------------------------------+

The keys in the hash table index the terms in the source of the map.  If a key
is missing, that map is taken to be the zero map. We illustrate by constructing
a map of chain complexes having nonzero degree, and omitting one key in the
hash table.

+------------------------------------------------------------------------+
|i10 : E = D[-3]                                                         |
|                                                                        |
|       1      3      3      1                                           |
|o10 = R  <-- R  <-- R  <-- R                                            |
|                                                                        |
|      3      4      5      6                                            |
|                                                                        |
|o10 : Complex                                                           |
+------------------------------------------------------------------------+
|i11 : H = hashTable { 0 => map(E_3, C_0, 1),                            |
|          1 => map(E_4, C_1, {{a, 0, 0}, {-b, b^2, 0}, {0, -c^2, c^3}}),|
|          3 => map(E_6, C_3, {{a*b^2*c^3}})                             |
|          }                                                             |
|                                                                        |
|o11 = HashTable{0 => | 1 |            }                                 |
|                1 => {1} | a  0   0  |                                  |
|                     {1} | -b b2  0  |                                  |
|                     {1} | 0  -c2 c3 |                                  |
|                3 => {3} | ab2c3 |                                      |
|                                                                        |
|o11 : HashTable                                                         |
+------------------------------------------------------------------------+
|i12 : g = map(E, C, H, Degree => 3)                                     |
|                                                                        |
|           1             1                                              |
|o12 = 3 : R  <--------- R  : 0                                          |
|                | 1 |                                                   |
|                                                                        |
|           3                         3                                  |
|      4 : R  <--------------------- R  : 1                              |
|                {1} | a  0   0  |                                       |
|                {1} | -b b2  0  |                                       |
|                {1} | 0  -c2 c3 |                                       |
|                                                                        |
|           1                     1                                      |
|      6 : R  <----------------- R  : 3                                  |
|                {3} | ab2c3 |                                           |
|                                                                        |
|o12 : ComplexMap                                                        |
+------------------------------------------------------------------------+
|i13 : g_2                                                               |
|                                                                        |
|o13 = 0                                                                 |
|                                                                        |
|              3       3                                                 |
|o13 : Matrix R  <--- R                                                  |
+------------------------------------------------------------------------+
|i14 : assert(g_1 == f_1)                                                |
+------------------------------------------------------------------------+
|i15 : assert(g != f)                                                    |
+------------------------------------------------------------------------+
|i16 : assert isWellDefined g                                            |
+------------------------------------------------------------------------+
|i17 : assert isHomogeneous g                                            |
+------------------------------------------------------------------------+
|i18 : assert(degree g == 3)                                             |
+------------------------------------------------------------------------+
|i19 : assert not isComplexMorphism g                                    |
+------------------------------------------------------------------------+
|i20 : assert not isCommutative g                                        |
+------------------------------------------------------------------------+
|i21 : assert(source g == C)                                             |
+------------------------------------------------------------------------+
|i22 : assert(target g == E)                                             |
+------------------------------------------------------------------------+

This is the primary constructor used by all of the more user friendly methods
for constructing a chain complex.

Caveat
======

This constructor minimizes computation and does very little error checking. To
verify that a complex is well constructed, use isWellDefined(ComplexMap).

See also
========

  * ComplexMap -- the class of all maps between chain
    complexes
  * map(Complex,Complex,Function),
    -- make a map of chain complexes
  * isWellDefined(ComplexMap) -- whether
    a map of chain complexes is well-defined
  * isHomogeneous(ComplexMap) -- whether
    a map of complexes is homogeneous
  * degree(ComplexMap) -- get the degree of a
    map of chain complexes
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes
  * isCommutative(ComplexMap) -- whether
    a complex map commutes with the differentials
  * source(ComplexMap) -- get the source of a
    map of chain complexes
  * target(ComplexMap) -- get the target of a
    map of chain complexes

Ways to use this method:
========================

  * map(Complex,Complex,HashTable)
    -- make a map of chain complexes

map(Complex,Complex,List) -- make a map of chain complexes
**********************************************************

Synopsis
========

  * Function: map (Macaulay2Doc),
  * Usage:
        f = map(D, C, L)
  * Inputs:
      * C, a complex,
      * D, a complex,
      * L, a list (Macaulay2Doc), consisting of either matrices, or
        lists of maps of complexes
  * Optional inputs (Macaulay2Doc),:
      * Degree (Macaulay2Doc), => an integer (Macaulay2Doc),
        default value null, the degree of the resulting map
      * DegreeLift (Macaulay2Doc), => ...,
        default value null, unused
      * DegreeMap (Macaulay2Doc), => ...,
        default value null, unused
  * Outputs:
      * f, a map of complexes, from $C$ to $D$

Description
===========

A map of complexes $f \colon C \rightarrow D$ of degree $d$ is a sequence of
maps $f_i \colon C_i \rightarrow D_{d+i}$. No relationship between the maps
$f_i$ and and the differentials of either $C$ or $D$ is assumed.

This method has two very different usages.  The first is to construct a chain
complex map from a list of matrices.  The second constructs a chain complex map
from essentially a block matrix whose entries are chain complex maps.

In the first case, we construct a map of chain complexes by specifying the
individual maps between the terms.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c];                                                      |
+-----------------------------------------------------------------------------+
|i2 : C = freeResolution coker matrix{{a^2-b^2,b^3-c^3,c^4}}                  |
|                                                                             |
|      1      3      3      1                                                 |
|o2 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : D = freeResolution coker vars R                                         |
|                                                                             |
|      1      3      3      1                                                 |
|o3 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     0      1      2      3                                                  |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : L = {map(D_0, C_0, 1),                                                  |
|         map(D_1, C_1, {{a, 0, 0}, {-b, b^2, 0}, {0, -c^2, c^3}}),           |
|         map(D_2, C_2, {{a*b^2, 0, 0}, {-a*c^2, a*c^3, 0}, {b*c^2, -b*c^3,   |
|         map(D_3, C_3, {{a*b^2*c^3}})                                        |
|         }                                                                   |
|                                                                             |
|o4 = {| 1 |, {1} | a  0   0  |, {2} | ab2  0    0    |, {3} | ab2c3 |}       |
|             {1} | -b b2  0  |  {2} | -ac2 ac3  0    |                       |
|             {1} | 0  -c2 c3 |  {2} | bc2  -bc3 b2c3 |                       |
|                                                                             |
|o4 : List                                                                    |
|-----------------------------------------------------------------------------|
|b^2*c^3}}),                                                                  |
+-----------------------------------------------------------------------------+
|i5 : f = map(D, C, L)                                                        |
|                                                                             |
|          1             1                                                    |
|o5 = 0 : R  <--------- R  : 0                                                |
|               | 1 |                                                         |
|                                                                             |
|          3                         3                                        |
|     1 : R  <--------------------- R  : 1                                    |
|               {1} | a  0   0  |                                             |
|               {1} | -b b2  0  |                                             |
|               {1} | 0  -c2 c3 |                                             |
|                                                                             |
|          3                              3                                   |
|     2 : R  <-------------------------- R  : 2                               |
|               {2} | ab2  0    0    |                                        |
|               {2} | -ac2 ac3  0    |                                        |
|               {2} | bc2  -bc3 b2c3 |                                        |
|                                                                             |
|          1                     1                                            |
|     3 : R  <----------------- R  : 3                                        |
|               {3} | ab2c3 |                                                 |
|                                                                             |
|o5 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i6 : assert isWellDefined f                                                  |
+-----------------------------------------------------------------------------+
|i7 : assert isHomogeneous f                                                  |
+-----------------------------------------------------------------------------+
|i8 : assert(degree f == 0)                                                   |
+-----------------------------------------------------------------------------+
|i9 : assert isComplexMorphism f                                              |
+-----------------------------------------------------------------------------+

In the second, we construct a map of chain complexes via a block matrix whose
individual entries are already maps of chain complexes. We illustrate by
constructing a mapping cone.

+-----------------------------------------------------------------------------+
|i10 : f = extend(D,C,id_(R^1))                                               |
|                                                                             |
|           1             1                                                   |
|o10 = 0 : R  <--------- R  : 0                                               |
|                | 1 |                                                        |
|                                                                             |
|           3                         3                                       |
|      1 : R  <--------------------- R  : 1                                   |
|                {1} | a  0   0  |                                            |
|                {1} | -b b2  0  |                                            |
|                {1} | 0  -c2 c3 |                                            |
|                                                                             |
|           3                              3                                  |
|      2 : R  <-------------------------- R  : 2                              |
|                {2} | ab2  0    0    |                                       |
|                {2} | -ac2 ac3  0    |                                       |
|                {2} | bc2  -bc3 b2c3 |                                       |
|                                                                             |
|           1                     1                                           |
|      3 : R  <----------------- R  : 3                                       |
|                {3} | ab2c3 |                                                |
|                                                                             |
|o10 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i11 : assert(degree f == 0)                                                  |
+-----------------------------------------------------------------------------+
|i12 : g = map(D, C[-1], f[-1], Degree => -1) -- a variant of f having degree |
|                                                                             |
|           1             1                                                   |
|o12 = 0 : R  <--------- R  : 1                                               |
|                | 1 |                                                        |
|                                                                             |
|           3                         3                                       |
|      1 : R  <--------------------- R  : 2                                   |
|                {1} | a  0   0  |                                            |
|                {1} | -b b2  0  |                                            |
|                {1} | 0  -c2 c3 |                                            |
|                                                                             |
|           3                              3                                  |
|      2 : R  <-------------------------- R  : 3                              |
|                {2} | ab2  0    0    |                                       |
|                {2} | -ac2 ac3  0    |                                       |
|                {2} | bc2  -bc3 b2c3 |                                       |
|                                                                             |
|           1                     1                                           |
|      3 : R  <----------------- R  : 4                                       |
|                {3} | ab2c3 |                                                |
|                                                                             |
|o12 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|-1                                                                           |
+-----------------------------------------------------------------------------+
|i13 : cf = map(E = C[-1] ++ D, E, {                                          |
|              {dd^(C[-1]),    0},                                            |
|              {         g, dd^D}                                             |
|              })                                                             |
|                                                                             |
|           1                   4                                             |
|o13 = 0 : R  <--------------- R  : 1                                         |
|                | 1 a b c |                                                  |
|                                                                             |
|           4                                          6                      |
|      1 : R  <-------------------------------------- R  : 2                  |
|                {0} | -a2+b2 -b3+c3 -c4 0  0  0  |                           |
|                {1} | a      0      0   -b -c 0  |                           |
|                {1} | -b     b2     0   a  0  -c |                           |
|                {1} | 0      -c2    c3  0  a  b  |                           |
|                                                                             |
|           6                                       4                         |
|      2 : R  <----------------------------------- R  : 3                     |
|                {2} | b3-c3  c4     0      0  |                              |
|                {3} | -a2+b2 0      c4     0  |                              |
|                {4} | 0      -a2+b2 -b3+c3 0  |                              |
|                {2} | ab2    0      0      c  |                              |
|                {2} | -ac2   ac3    0      -b |                              |
|                {2} | bc2    -bc3   b2c3   a  |                              |
|                                                                             |
|           4                      1                                          |
|      3 : R  <------------------ R  : 4                                      |
|                {5} | -c4    |                                               |
|                {6} | b3-c3  |                                               |
|                {7} | -a2+b2 |                                               |
|                {3} | ab2c3  |                                               |
|                                                                             |
|o13 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i14 : assert isWellDefined cf                                                |
+-----------------------------------------------------------------------------+
|i15 : assert(degree cf == -1)                                                |
+-----------------------------------------------------------------------------+

We convert this map of complexes cf into the differential of the mapping cone.
For the following constructor, the source and target of the input must be
identical, in this case the chain complex $E$.

+------------------------------------+
|i16 : conef = complex cf            |
|                                    |
|       1      4      6      4      1|
|o16 = R  <-- R  <-- R  <-- R  <-- R |
|                                    |
|      0      1      2      3      4 |
|                                    |
|o16 : Complex                       |
+------------------------------------+
|i17 : assert isWellDefined conef    |
+------------------------------------+
|i18 : assert(conef == cone f)       |
+------------------------------------+

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * map(Complex,Complex,HashTable)
    -- make a map of chain complexes
  * degree(ComplexMap) -- get the degree of a
    map of chain complexes
  * extend(Complex,Complex,Matrix)
    -- extend a map of
    modules to a map of chain complexes
  * cone(ComplexMap) -- make the mapping cone of a
    morphism of chain complexes

Ways to use this method:
========================

  * map(Complex,Complex,List) -- make
    a map of chain complexes

map(Complex,Complex,ZZ) -- make the zero map or identity between chain complexes
********************************************************************************

Synopsis
========

  * Function: map (Macaulay2Doc),
  * Usage:
        f = map(D, C, 0)
        f = map(C, C, 1)
  * Inputs:
      * C, a complex,
      * D, a complex,
      * 0, an integer (Macaulay2Doc), or 1
  * Optional inputs (Macaulay2Doc),:
      * Degree (Macaulay2Doc), => an integer (Macaulay2Doc),
        default value null, the degree of the resulting map
      * DegreeLift (Macaulay2Doc), => ...,
        default value null, unused
      * DegreeMap (Macaulay2Doc), => ...,
        default value null, unused
  * Outputs:
      * f, a map of complexes, the zero map from $C$ to $D$
        or the identity map from $C$ to $C$

Description
===========

A map of complexes $f : C \rightarrow D$ of degree $d$ is a sequence of maps
$f_i : C_i \rightarrow D_{d+i}$.

We construct the zero map between two chain complexes.

+-----------------------------------------------------+
|i1 : R = QQ[a,b,c]                                   |
|                                                     |
|o1 = R                                               |
|                                                     |
|o1 : PolynomialRing                                  |
+-----------------------------------------------------+
|i2 : C = freeResolution coker vars R                 |
|                                                     |
|      1      3      3      1                         |
|o2 = R  <-- R  <-- R  <-- R                          |
|                                                     |
|     0      1      2      3                          |
|                                                     |
|o2 : Complex                                         |
+-----------------------------------------------------+
|i3 : D = freeResolution coker matrix{{a^2, b^2, c^2}}|
|                                                     |
|      1      3      3      1                         |
|o3 = R  <-- R  <-- R  <-- R                          |
|                                                     |
|     0      1      2      3                          |
|                                                     |
|o3 : Complex                                         |
+-----------------------------------------------------+
|i4 : f = map(D, C, 0)                                |
|                                                     |
|o4 = 0                                               |
|                                                     |
|o4 : ComplexMap                                      |
+-----------------------------------------------------+
|i5 : assert isWellDefined f                          |
+-----------------------------------------------------+
|i6 : assert isComplexMorphism f                      |
+-----------------------------------------------------+
|i7 : g = map(C, C, 0, Degree => 13)                  |
|                                                     |
|o7 = 0                                               |
|                                                     |
|o7 : ComplexMap                                      |
+-----------------------------------------------------+
|i8 : assert isWellDefined g                          |
+-----------------------------------------------------+
|i9 : assert(degree g == 13)                          |
+-----------------------------------------------------+
|i10 : assert not isComplexMorphism g                 |
+-----------------------------------------------------+
|i11 : assert isCommutative g                         |
+-----------------------------------------------------+
|i12 : assert isHomogeneous g                         |
+-----------------------------------------------------+
|i13 : assert(source g == C)                          |
+-----------------------------------------------------+
|i14 : assert(target g == C)                          |
+-----------------------------------------------------+

Using this function to create the identity map is the same as using id _ Complex.

+-----------------------------------+
|i15 : assert(map(C, C, 1) === id_C)|
+-----------------------------------+

See also
========

  * ComplexMap -- the class of all maps between chain
    complexes
  * map(Complex,Complex,Function),
    -- make a map of chain complexes
  * isWellDefined(ComplexMap) -- whether
    a map of chain complexes is well-defined
  * isHomogeneous(ComplexMap) -- whether
    a map of complexes is homogeneous
  * degree(ComplexMap) -- get the degree of a
    map of chain complexes
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes
  * isCommutative(ComplexMap) -- whether
    a complex map commutes with the differentials
  * source(ComplexMap) -- get the source of a
    map of chain complexes
  * target(ComplexMap) -- get the target of a
    map of chain complexes
  * id _ Complex -- the identity map of a chain complex

Ways to use this method:
========================

  * map(Complex,Complex,ZZ) -- make the
    zero map or identity between chain complexes

minimalPresentation(Complex) -- minimal presentation of all terms in a complex
******************************************************************************

Synopsis
========

  * Function: minimalPresentation (Macaulay2Doc),
  * Usage:
        D = minimalPresentation C
        D = prune C
        h = minimalPresentation f
        h = prune f
  * Inputs:
      * C, a complex, or $f$ a map of complexes,
  * Optional inputs (Macaulay2Doc),:
      * Exclude (Macaulay2Doc), => ...,
        default value {}, unused
  * Outputs:
      * D, a complex, isomorphic to the input, where each term
        is replaced by a minimally presented model, or $h$ a map of complexes,
        where the source and target are minimally
        presented
  * Consequences:
      * The isomorphism $g : D \to C$ is available as g = D.cache.pruningMap.
        The inverse isomorphism can be obtained as g^-1

Description
===========

This is frequently useful to make the output of certain operations readable or
understandable.  This operation is functorial, applying both to complexes and
complex maps.

In particular, homology often needs to be pruned to be understood.  For
instance, this is useful for recognizing when terms given by subquotient
modules are actually zero.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a,b,c,d,e];                                                  |
+-----------------------------------------------------------------------------+
|i2 : I = ideal(a,b) * ideal(c,d,e)                                           |
|                                                                             |
|o2 = ideal (a*c, a*d, a*e, b*c, b*d, b*e)                                    |
|                                                                             |
|o2 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i3 : F = dual freeResolution I                                               |
|                                                                             |
|      1      5      9      6      1                                          |
|o3 = S  <-- S  <-- S  <-- S  <-- S                                           |
|                                                                             |
|     -4     -3     -2     -1     0                                           |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : C = HH F                                                                |
|                                                                             |
|o4 = cokernel {-5} | -e d -c -b a | <-- subquotient ({-4} | d c  0 b  0 0  a |
|                                                     {-4} | e 0  c 0  b 0  0 |
|     -4                                              {-4} | 0 -e d 0  0 b  0 |
|                                                     {-4} | 0 0  0 -e d -c 0 |
|                                                     {-4} | 0 0  0 0  0 0  e |
|                                                                             |
|                                        -3                                   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o4 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|0  0 0 |, {-4} | d -c -b a 0  0  0  0  0 |) <-- subquotient ({-3} | c b a  0 |
|a  0 0 |  {-4} | e 0  0  0 -c -b a  0  0 |                   {-3} | d 0 0  b |
|0  a 0 |  {-4} | 0 e  0  0 -d 0  0  -b a |                   {-3} | 0 d 0  -c|
|0  0 a |  {-4} | 0 0  e  0 0  -d 0  c  0 |                   {-3} | 0 0 -d 0 |
|-d c b |  {-4} | 0 0  0  e 0  0  -d 0  c |                   {-3} | e 0 0  0 |
|                                                             {-3} | 0 e 0  0 |
|                                                             {-3} | 0 0 -e 0 |
|                                                             {-3} | 0 0 0  e |
|                                                             {-3} | 0 0 0  0 |
|                                                                             |
|                                                -2                           |
|-----------------------------------------------------------------------------|
|0  0  0 |, {-3} | -b a  0  0  0  0 |) <-- subquotient ({-2} | ac |, {-2} | ac|
|0  a  0 |  {-3} | 0  0  -b a  0  0 |                   {-2} | bc |  {-2} | bc|
|0  0  0 |  {-3} | -d 0  c  0  0  0 |                   {-2} | ad |  {-2} | ad|
|0  c  0 |  {-3} | 0  -d 0  c  0  0 |                   {-2} | bd |  {-2} | bd|
|b  0  a |  {-3} | 0  0  0  0  -b a |                   {-2} | ae |  {-2} | ae|
|-c 0  0 |  {-3} | -e 0  0  0  c  0 |                   {-2} | be |  {-2} | be|
|0  0  c |  {-3} | 0  -e 0  0  0  c |                                         |
|-d 0  0 |  {-3} | 0  0  -e 0  d  0 |      -1                                 |
|0  -e d |  {-3} | 0  0  0  -e 0  d |                                         |
|-----------------------------------------------------------------------------|
||) <-- image 0                                                               |
||                                                                            |
||      0                                                                     |
||                                                                            |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i5 : D = prune C                                                             |
|                                                                             |
|o5 = cokernel {-5} | e d c b a | <-- cokernel {-3} | e d c | <-- cokernel    |
|                                                                             |
|     -4                              -3                          -2          |
|                                                                             |
|o5 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|{-2} | b a |                                                                 |
+-----------------------------------------------------------------------------+
|i6 : g = D.cache.pruningMap                                                  |
|                                                                             |
|o6 = -4 : cokernel {-5} | -e d -c -b                                         |
|                                                                             |
|                                                                             |
|     -3 : subquotient ({-4} | d c  0                                         |
|                       {-4} | e 0  c                                         |
|                       {-4} | 0 -e d                                         |
|                       {-4} | 0 0  0                                         |
|                       {-4} | 0 0  0                                         |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|     -2 : subquotient ({-3} | c b a                                          |
|                       {-3} | d 0 0                                          |
|                       {-3} | 0 d 0                                          |
|                       {-3} | 0 0 -d                                         |
|                       {-3} | e 0 0                                          |
|                       {-3} | 0 e 0                                          |
|                       {-3} | 0 0 -e                                         |
|                       {-3} | 0 0 0                                          |
|                       {-3} | 0 0 0                                          |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|a | <-------------- cokernel {-5} | e d c b a | : -4                         |
|       {-5} | 1 |                                                            |
|                                                                             |
|b  0 0  a 0  0 0 |, {-4} | d -c -b a 0  0  0  0  0 |) <--------------        |
|0  b 0  0 a  0 0 |  {-4} | e 0  0  0 -c -b a  0  0 |     {-3} | 0 |          |
|0  0 b  0 0  a 0 |  {-4} | 0 e  0  0 -d 0  0  -b a |     {-3} | 0 |          |
|-e d -c 0 0  0 a |  {-4} | 0 0  e  0 0  -d 0  c  0 |     {-3} | 0 |          |
|0  0 0  e -d c b |  {-4} | 0 0  0  e 0  0  -d 0  c |     {-3} | 0 |          |
|                                                         {-3} | 0 |          |
|                                                         {-3} | 0 |          |
|                                                         {-3} | 0 |          |
|                                                         {-3} | 0 |          |
|                                                         {-3} | 0 |          |
|                                                         {-3} | 1 |          |
|                                                                             |
|0  0  0  0 |, {-3} | -b a  0  0  0  0 |) <-------------- cokernel {-2}       |
|b  0  a  0 |  {-3} | 0  0  -b a  0  0 |     {-2} | 1 |                       |
|-c 0  0  0 |  {-3} | -d 0  c  0  0  0 |     {-2} | 0 |                       |
|0  0  c  0 |  {-3} | 0  -d 0  c  0  0 |     {-2} | 0 |                       |
|0  b  0  a |  {-3} | 0  0  0  0  -b a |     {-2} | 0 |                       |
|0  -c 0  0 |  {-3} | -e 0  0  0  c  0 |     {-2} | 0 |                       |
|0  0  0  c |  {-3} | 0  -e 0  0  0  c |     {-2} | 0 |                       |
|e  -d 0  0 |  {-3} | 0  0  -e 0  d  0 |     {-2} | 0 |                       |
|0  0  -e d |  {-3} | 0  0  0  -e 0  d |                                      |
|-----------------------------------------------------------------------------|
|cokernel {-3} | e d c | : -3                                                 |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
| | b a | : -2                                                                |
+-----------------------------------------------------------------------------+
|i7 : assert isWellDefined g                                                  |
+-----------------------------------------------------------------------------+
|i8 : assert isComplexMorphism g                                              |
+-----------------------------------------------------------------------------+
|i9 : assert (target g == C)                                                  |
+-----------------------------------------------------------------------------+
|i10 : assert (source g == D)                                                 |
+-----------------------------------------------------------------------------+
|i11 : g^-1                                                                   |
|                                                                             |
|o11 = -4 : cokernel {-5} | e d c                                             |
|                                                                             |
|                                                                             |
|      -3 : cokernel {-3} | e d c                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      -2 : cokernel {-2} | b a |                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o11 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|b a | <-------------- cokernel {-5} | -e d -c -b a | : -4                    |
|         {-5} | 1 |                                                          |
|                                                                             |
|| <-------------------------------- subquotient ({-4} | d c  0 b  0 0  a 0   |
|     {-3} | 0 0 0 0 0 0 0 0 0 1 |                {-4} | e 0  c 0  b 0  0 a   |
|                                                 {-4} | 0 -e d 0  0 b  0 0   |
|                                                 {-4} | 0 0  0 -e d -c 0 0   |
|                                                 {-4} | 0 0  0 0  0 0  e -d  |
|                                                                             |
|<-------------------------- subquotient ({-3} | c b a  0  0  0  0 |, {-3} |  |
|   {-2} | 1 0 0 0 0 0 0 |                {-3} | d 0 0  b  0  a  0 |  {-3} |  |
|                                         {-3} | 0 d 0  -c 0  0  0 |  {-3} |  |
|                                         {-3} | 0 0 -d 0  0  c  0 |  {-3} |  |
|                                         {-3} | e 0 0  0  b  0  a |  {-3} |  |
|                                         {-3} | 0 e 0  0  -c 0  0 |  {-3} |  |
|                                         {-3} | 0 0 -e 0  0  0  c |  {-3} |  |
|                                         {-3} | 0 0 0  e  -d 0  0 |  {-3} |  |
|                                         {-3} | 0 0 0  0  0  -e d |  {-3} |  |
|-----------------------------------------------------------------------------|
|0 0 |, {-4} | d -c -b a 0  0  0  0  0 |) : -3                                |
|0 0 |  {-4} | e 0  0  0 -c -b a  0  0 |                                      |
|a 0 |  {-4} | 0 e  0  0 -d 0  0  -b a |                                      |
|0 a |  {-4} | 0 0  e  0 0  -d 0  c  0 |                                      |
|c b |  {-4} | 0 0  0  e 0  0  -d 0  c |                                      |
|                                                                             |
|-b a  0  0  0  0 |) : -2                                                     |
|0  0  -b a  0  0 |                                                           |
|-d 0  c  0  0  0 |                                                           |
|0  -d 0  c  0  0 |                                                           |
|0  0  0  0  -b a |                                                           |
|-e 0  0  0  c  0 |                                                           |
|0  -e 0  0  0  c |                                                           |
|0  0  -e 0  d  0 |                                                           |
|0  0  0  -e 0  d |                                                           |
+-----------------------------------------------------------------------------+
|i12 : assert(g*g^-1 == 1 and g^-1*g == 1)                                    |
+-----------------------------------------------------------------------------+

The image of a map of complexes also becomes more understandable via pruning.

+-----------------------------------------------------------------------------+
|i13 : S = ZZ/101[a,b,c];                                                     |
+-----------------------------------------------------------------------------+
|i14 : I = ideal(a^2,b^2,c^2);                                                |
|                                                                             |
|o14 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i15 : J = I + ideal(a*b*c);                                                  |
|                                                                             |
|o15 : Ideal of S                                                             |
+-----------------------------------------------------------------------------+
|i16 : FI = freeResolution I                                                  |
|                                                                             |
|       1      3      3      1                                                |
|o16 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o16 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i17 : FJ = freeResolution J                                                  |
|                                                                             |
|       1      4      6      3                                                |
|o17 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o17 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i18 : f = randomComplexMap(FJ, FI ** S^{-1}, Cycle => true)                  |
|                                                                             |
|           1                       1                                         |
|o18 = 0 : S  <------------------- S  : 0                                     |
|                | 32a-36b-30c |                                              |
|                                                                             |
|           4                                                   3             |
|      1 : S  <----------------------------------------------- S  : 1         |
|                {2} | 32a-36b-30c 0           0           |                  |
|                {2} | 0           32a-36b-30c 0           |                  |
|                {2} | 0           0           32a-36b-30c |                  |
|                {3} | 0           0           0           |                  |
|                                                                             |
|           6                                                  3              |
|      2 : S  <---------------------------------------------- S  : 2          |
|                {4} | 32a-36b+42c -19c       19c         |                   |
|                {4} | 29b+10c     19b-29c    -19b+22c    |                   |
|                {4} | -29a+29c    -19a-24c   19a+8c      |                   |
|                {4} | -10b        32a-7b-30c -22b        |                   |
|                {4} | -10a-29b    29a+24b    -22a-8b     |                   |
|                {4} | -29a        24a        24a-36b-30c |                   |
|                                                                             |
|           3                                        1                        |
|      3 : S  <------------------------------------ S  : 3                    |
|                {5} | 19a2+19b2+32ac-36bc+42c2 |                             |
|                {5} | -22a2-32ab+7b2+30bc-10c2 |                             |
|                {5} | 24a2-36ab-24b2-30ac-29c2 |                             |
|                                                                             |
|o18 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i19 : C = image f                                                            |
|                                                                             |
|o19 = image | 32a-36b-30c | <-- image {2} | 32a-36b-30c 0                    |
|                                      {2} | 0           32a-36b-30c          |
|      0                               {2} | 0           0                    |
|                                      {3} | 0           0                    |
|                                                                             |
|                                1                                            |
|                                                                             |
|                                                                             |
|                                                                             |
|o19 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0           | <-- image {4} | 32a-36b+42c -19c       19c         | <-- image |
|0           |           {4} | 29b+10c     19b-29c    -19b+22c    |           |
|32a-36b-30c |           {4} | -29a+29c    -19a-24c   19a+8c      |           |
|0           |           {4} | -10b        32a-7b-30c -22b        |           |
|                        {4} | -10a-29b    29a+24b    -22a-8b     |     3     |
|                        {4} | -29a        24a        24a-36b-30c |           |
|                                                                             |
|                  2                                                          |
|-----------------------------------------------------------------------------|
|{5} | 19a2+19b2+32ac-36bc+42c2 |                                             |
|{5} | -22a2-32ab+7b2+30bc-10c2 |                                             |
|{5} | 24a2-36ab-24b2-30ac-29c2 |                                             |
+-----------------------------------------------------------------------------+
|i20 : D = prune C                                                            |
|                                                                             |
|       1      3      3      1                                                |
|o20 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o20 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i21 : g = D.cache.pruningMap                                                 |
|                                                                             |
|                                                1                            |
|o21 = 0 : image | 32a-36b-30c | <------------- S                             |
|                                   {1} | 1 |                                 |
|                                                                             |
|                                                                             |
|      1 : image {2} | 32a-36b-30c 0           0                              |
|                {2} | 0           32a-36b-30c 0                              |
|                {2} | 0           0           32a                            |
|                {3} | 0           0           0                              |
|                                                                             |
|                                                                             |
|      2 : image {4} | 32a-36b+42c -19c       19c                             |
|                {4} | 29b+10c     19b-29c    -19b                            |
|                {4} | -29a+29c    -19a-24c   19a+                            |
|                {4} | -10b        32a-7b-30c -22b                            |
|                {4} | -10a-29b    29a+24b    -22a                            |
|                {4} | -29a        24a        24a-                            |
|                                                                             |
|                                                                             |
|      3 : image {5} | 19a2+19b2+32ac-36bc+42c2 |                             |
|                {5} | -22a2-32ab+7b2+30bc-10c2 |                             |
|                {5} | 24a2-36ab-24b2-30ac-29c2 |                             |
|                                                                             |
|o21 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
| : 0                                                                         |
|                                                                             |
|                                                                             |
|                               3                                             |
|         | <----------------- S  : 1                                         |
|         |    {3} | 1 0 0 |                                                  |
|-36b-30c |    {3} | 0 1 0 |                                                  |
|         |    {3} | 0 0 1 |                                                  |
|                                                                             |
|                              3                                              |
|        | <----------------- S  : 2                                          |
|+22c    |    {5} | 1 0 0 |                                                   |
|8c      |    {5} | 0 1 0 |                                                   |
|        |    {5} | 0 0 1 |                                                   |
|-8b     |                                                                    |
|36b-30c |                                                                    |
|                                                                             |
|                1                                                            |
|<------------- S  : 3                                                        |
|   {7} | 1 |                                                                 |
+-----------------------------------------------------------------------------+
|i22 : assert isWellDefined g                                                 |
+-----------------------------------------------------------------------------+
|i23 : assert isComplexMorphism g                                             |
+-----------------------------------------------------------------------------+
|i24 : assert (target g == C)                                                 |
+-----------------------------------------------------------------------------+
|i25 : assert (source g == D)                                                 |
+-----------------------------------------------------------------------------+
|i26 : g^-1                                                                   |
|                                                                             |
|           1                                                                 |
|o26 = 0 : S  <------------- image | 32a-36b-30c | : 0                        |
|                {1} | 1 |                                                    |
|                                                                             |
|           3                                                                 |
|      1 : S  <----------------- image {2} | 32a-36b-30c 0           0        |
|                {3} | 1 0 0 |         {2} | 0           32a-36b-30c 0        |
|                {3} | 0 1 0 |         {2} | 0           0           32a-36b  |
|                {3} | 0 0 1 |         {3} | 0           0           0        |
|                                                                             |
|           3                                                                 |
|      2 : S  <----------------- image {4} | 32a-36b+42c -19c       19c       |
|                {5} | 1 0 0 |         {4} | 29b+10c     19b-29c    -19b+22c  |
|                {5} | 0 1 0 |         {4} | -29a+29c    -19a-24c   19a+8c    |
|                {5} | 0 0 1 |         {4} | -10b        32a-7b-30c -22b      |
|                                      {4} | -10a-29b    29a+24b    -22a-8b   |
|                                      {4} | -29a        24a        24a-36b-  |
|                                                                             |
|           1                                                                 |
|      3 : S  <------------- image {5} | 19a2+19b2+32ac-36bc+42c2 | : 3       |
|                {7} | 1 |         {5} | -22a2-32ab+7b2+30bc-10c2 |           |
|                                  {5} | 24a2-36ab-24b2-30ac-29c2 |           |
|                                                                             |
|o26 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|     | : 1                                                                   |
|     |                                                                       |
|-30c |                                                                       |
|     |                                                                       |
|                                                                             |
|                                                                             |
|    | : 2                                                                    |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|    |                                                                        |
|30c |                                                                        |
+-----------------------------------------------------------------------------+
|i27 : assert(g*g^-1 == 1 and g^-1*g == 1)                                    |
+-----------------------------------------------------------------------------+

One can directly prune the map of complexes $f$.

+--------------------------------------------------------------------+
|i28 : h = prune f                                                   |
|                                                                    |
|           1                       1                                |
|o28 = 0 : S  <------------------- S  : 0                            |
|                | 32a-36b-30c |                                     |
|                                                                    |
|           4                                                   3    |
|      1 : S  <----------------------------------------------- S  : 1|
|                {2} | 32a-36b-30c 0           0           |         |
|                {2} | 0           32a-36b-30c 0           |         |
|                {2} | 0           0           32a-36b-30c |         |
|                {3} | 0           0           0           |         |
|                                                                    |
|           6                                                  3     |
|      2 : S  <---------------------------------------------- S  : 2 |
|                {4} | 32a-36b+42c -19c       19c         |          |
|                {4} | 29b+10c     19b-29c    -19b+22c    |          |
|                {4} | -29a+29c    -19a-24c   19a+8c      |          |
|                {4} | -10b        32a-7b-30c -22b        |          |
|                {4} | -10a-29b    29a+24b    -22a-8b     |          |
|                {4} | -29a        24a        24a-36b-30c |          |
|                                                                    |
|           3                                        1               |
|      3 : S  <------------------------------------ S  : 3           |
|                {5} | 19a2+19b2+32ac-36bc+42c2 |                    |
|                {5} | -22a2-32ab+7b2+30bc-10c2 |                    |
|                {5} | 24a2-36ab-24b2-30ac-29c2 |                    |
|                                                                    |
|o28 : ComplexMap                                                    |
+--------------------------------------------------------------------+
|i29 : assert(source h === prune source f)                           |
+--------------------------------------------------------------------+
|i30 : assert(target h === prune target f)                           |
+--------------------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * minimize(Complex) -- a quasi-isomorphic
    complex whose terms have minimal rank
  * minimalPresentation(Module) (Macaulay2Doc)
    -- minimal presentation of a
    module
  * randomComplexMap -- a
    random map of chain complexes
  * freeResolution -- compute a free resolution of a
    module or ideal
  * isComplexMorphism -- whether a
    complex map is a morphism of complexes

Ways to use this method:
========================

  * minimalPresentation(Complex), --
    minimal presentation of all terms in a complex
  * "minimalPresentation(ComplexMap)"

minimize(Complex) -- a quasi-isomorphic complex whose terms have minimal rank
*****************************************************************************

Synopsis
========

  * Function: minimize,
  * Usage:
        D = minimize C
  * Inputs:
      * C, a complex, graded, whose terms are all free modules
  * Outputs:
      * D, a complex, graded, whose terms are all free modules
        of minimal rank
  * Consequences:
      * The projection morphism $g : C \to D$ is available as g =
        D.cache.minimizingMap.

Description
===========

This method essentially removes all scalar units from the matrices in the
differential of $C$.

We illustrate this in a simple example.

+----------------------------------------------------------+
|i1 : S = ZZ/32003[a,b];                                   |
+----------------------------------------------------------+
|i2 : I = ideal(a^2-b^2, a*b)                              |
|                                                          |
|             2    2                                       |
|o2 = ideal (a  - b , a*b)                                 |
|                                                          |
|o2 : Ideal of S                                           |
+----------------------------------------------------------+
|i3 : C = freeResolution(I, FastNonminimal=>true)          |
|                                                          |
|      1      2      1                                     |
|o3 = S  <-- S  <-- S                                      |
|                                                          |
|     0      1      2                                      |
|                                                          |
|o3 : Complex                                              |
+----------------------------------------------------------+
|i4 : betti C                                              |
|                                                          |
|            0 1 2                                         |
|o4 = total: 1 2 1                                         |
|         0: 1 . .                                         |
|         1: . 2 .                                         |
|         2: . . 1                                         |
|                                                          |
|o4 : BettiTally                                           |
+----------------------------------------------------------+
|i5 : D = minimize C                                       |
|                                                          |
|      1      2      1                                     |
|o5 = S  <-- S  <-- S                                      |
|                                                          |
|     0      1      2                                      |
|                                                          |
|o5 : Complex                                              |
+----------------------------------------------------------+
|i6 : assert(isWellDefined D and isHomogeneous D)          |
+----------------------------------------------------------+
|i7 : betti D                                              |
|                                                          |
|            0 1 2                                         |
|o7 = total: 1 2 1                                         |
|         0: 1 . .                                         |
|         1: . 2 .                                         |
|         2: . . 1                                         |
|                                                          |
|o7 : BettiTally                                           |
+----------------------------------------------------------+
|i8 : g = D.cache.minimizingMap                            |
|                                                          |
|          1             1                                 |
|o8 = 0 : S  <--------- S  : 0                             |
|               | 1 |                                      |
|                                                          |
|          2                   2                           |
|     1 : S  <--------------- S  : 1                       |
|               {2} | 1 0 |                                |
|               {2} | 0 1 |                                |
|                                                          |
|          1                 1                             |
|     2 : S  <------------- S  : 2                         |
|               {4} | 1 |                                  |
|                                                          |
|o8 : ComplexMap                                           |
+----------------------------------------------------------+
|i9 : assert isWellDefined g                               |
+----------------------------------------------------------+
|i10 : assert(isComplexMorphism g and isQuasiIsomorphism g)|
+----------------------------------------------------------+
|i11 : assert(source g == C)                               |
+----------------------------------------------------------+
|i12 : assert(target g == D)                               |
+----------------------------------------------------------+
|i13 : assert(coker g == 0)                                |
+----------------------------------------------------------+

The minimal complex $D$ is a direct summand of the original complex $C$.  The
natural inclusion of $D$ into $C$ can be constructed as follows.

+-----------------------------------------------+
|i14 : f = liftMapAlongQuasiIsomorphism(id_D, g)|
|                                               |
|           1             1                     |
|o14 = 0 : S  <--------- S  : 0                 |
|                | 1 |                          |
|                                               |
|           2                   2               |
|      1 : S  <--------------- S  : 1           |
|                {2} | 1 0 |                    |
|                {2} | 0 1 |                    |
|                                               |
|           1                 1                 |
|      2 : S  <------------- S  : 2             |
|                {4} | 1 |                      |
|                                               |
|o14 : ComplexMap                               |
+-----------------------------------------------+
|i15 : g*f == id_D                              |
|                                               |
|o15 = true                                     |
+-----------------------------------------------+
|i16 : assert(source f == D)                    |
+-----------------------------------------------+
|i17 : assert(target f == C)                    |
+-----------------------------------------------+
|i18 : assert(ker f == 0)                       |
+-----------------------------------------------+
|i19 : f*g                                      |
|                                               |
|           1             1                     |
|o19 = 0 : S  <--------- S  : 0                 |
|                | 1 |                          |
|                                               |
|           2                   2               |
|      1 : S  <--------------- S  : 1           |
|                {2} | 1 0 |                    |
|                {2} | 0 1 |                    |
|                                               |
|           1                 1                 |
|      2 : S  <------------- S  : 2             |
|                {4} | 1 |                      |
|                                               |
|o19 : ComplexMap                               |
+-----------------------------------------------+

The chain complex $D$ is a direct summand of $C$, giving rise to a split short
exact sequence of chain complexes.

+---------------------------------------+
|i20 : h = prune canonicalMap(C, ker g) |
|                                       |
|o20 = 0                                |
|                                       |
|o20 : ComplexMap                       |
+---------------------------------------+
|i21 : assert isShortExactSequence(g, h)|
+---------------------------------------+

Warning: If the input complex is not homogeneous, then the output is probably
not what one would expect.

+---------------------------------------------+
|i22 : S = ZZ/32003[a..d]                     |
|                                             |
|o22 = S                                      |
|                                             |
|o22 : PolynomialRing                         |
+---------------------------------------------+
|i23 : J = ideal(a*b*c-b*c, a*d-c, a^3-d^2*c) |
|                                             |
|                                    3      2 |
|o23 = ideal (a*b*c - b*c, a*d - c, a  - c*d )|
|                                             |
|o23 : Ideal of S                             |
+---------------------------------------------+
|i24 : CJ = freeResolution J                  |
|                                             |
|       1      3      4      2                |
|o24 = S  <-- S  <-- S  <-- S                 |
|                                             |
|      0      1      2      3                 |
|                                             |
|o24 : Complex                                |
+---------------------------------------------+
|i25 : assert not isHomogeneous CJ            |
+---------------------------------------------+
|i26 : D = minimize CJ                        |
|                                             |
|       1      3      3      1                |
|o26 = S  <-- S  <-- S  <-- S                 |
|                                             |
|      0      1      2      3                 |
|                                             |
|o26 : Complex                                |
+---------------------------------------------+
|i27 : isWellDefined D                        |
|                                             |
|o27 = true                                   |
+---------------------------------------------+
|i28 : prune HH D == prune HH CJ              |
|                                             |
|o28 = true                                   |
+---------------------------------------------+

See also
========

  * freeResolution -- compute a free resolution of a
    module or ideal
  * resolution(Complex) -- minimal free
    resolution of a complex
  * resolutionMap(Complex) -- map from a free resolution
    to the given complex
  * minimalPresentation(Complex), --
    minimal presentation of all terms in a complex

Ways to use this method:
========================

  * minimize(Complex) -- a quasi-isomorphic
    complex whose terms have minimal rank

naiveTruncation(Complex,ZZ,ZZ) -- drops all terms of a complex outside a given interval
***************************************************************************************

Synopsis
========

  * Function: naiveTruncation,
  * Usage:
        naiveTruncation(C, lo, hi)
  * Inputs:
      * C, a complex,
      * lo, an integer (Macaulay2Doc), or -infinity or null (the
        latter two give no lower bound)
      * hi, an integer (Macaulay2Doc), or infinity or null (the
        latter two give no upper bound)
  * Outputs:
      * a complex,

Description
===========

Returns a new complex which drops (sets to zero) all modules outside the given
range.

+-------------------------------------------+
|i1 : R = ZZ/101[a,b,c,d,e];                |
+-------------------------------------------+
|i2 : I = intersect(ideal(a,b),ideal(c,d,e))|
|                                           |
|o2 = ideal (b*e, a*e, b*d, a*d, b*c, a*c)  |
|                                           |
|o2 : Ideal of R                            |
+-------------------------------------------+
|i3 : C = freeResolution I                  |
|                                           |
|      1      6      9      5      1        |
|o3 = R  <-- R  <-- R  <-- R  <-- R         |
|                                           |
|     0      1      2      3      4         |
|                                           |
|o3 : Complex                               |
+-------------------------------------------+
|i4 : naiveTruncation(C, 1, 2)              |
|                                           |
|      6      9                             |
|o4 = R  <-- R                              |
|                                           |
|     1      2                              |
|                                           |
|o4 : Complex                               |
+-------------------------------------------+
|i5 : C16 = naiveTruncation(C, 1, 6)        |
|                                           |
|      6      9      5      1               |
|o5 = R  <-- R  <-- R  <-- R                |
|                                           |
|     1      2      3      4                |
|                                           |
|o5 : Complex                               |
+-------------------------------------------+
|i6 : isWellDefined C16                     |
|                                           |
|o6 = true                                  |
+-------------------------------------------+
|i7 : naiveTruncation(C, 1, infinity)       |
|                                           |
|      6      9      5      1               |
|o7 = R  <-- R  <-- R  <-- R                |
|                                           |
|     1      2      3      4                |
|                                           |
|o7 : Complex                               |
+-------------------------------------------+
|i8 : naiveTruncation(C, -13, 2)            |
|                                           |
|      1      6      9                      |
|o8 = R  <-- R  <-- R                       |
|                                           |
|     0      1      2                       |
|                                           |
|o8 : Complex                               |
+-------------------------------------------+
|i9 : naiveTruncation(C, -infinity, 2)      |
|                                           |
|      1      6      9                      |
|o9 = R  <-- R  <-- R                       |
|                                           |
|     0      1      2                       |
|                                           |
|o9 : Complex                               |
+-------------------------------------------+
|i10 : naiveTruncation(C, , 2)              |
|                                           |
|       1      6      9                     |
|o10 = R  <-- R  <-- R                      |
|                                           |
|      0      1      2                      |
|                                           |
|o10 : Complex                              |
+-------------------------------------------+

Truncation gives rise to a natural short exact sequence of complexes.

+--------------------------------------------------+
|i11 : C' = naiveTruncation(C,, 1)                 |
|                                                  |
|       1      6                                   |
|o11 = R  <-- R                                    |
|                                                  |
|      0      1                                    |
|                                                  |
|o11 : Complex                                     |
+--------------------------------------------------+
|i12 : C'' = naiveTruncation(C, 2, infinity)       |
|                                                  |
|       9      5      1                            |
|o12 = R  <-- R  <-- R                             |
|                                                  |
|      2      3      4                             |
|                                                  |
|o12 : Complex                                     |
+--------------------------------------------------+
|i13 : f = inducedMap(C, C')                       |
|                                                  |
|           1             1                        |
|o13 = 0 : R  <--------- R  : 0                    |
|                | 1 |                             |
|                                                  |
|           6                           6          |
|      1 : R  <----------------------- R  : 1      |
|                {2} | 1 0 0 0 0 0 |               |
|                {2} | 0 1 0 0 0 0 |               |
|                {2} | 0 0 1 0 0 0 |               |
|                {2} | 0 0 0 1 0 0 |               |
|                {2} | 0 0 0 0 1 0 |               |
|                {2} | 0 0 0 0 0 1 |               |
|                                                  |
|o13 : ComplexMap                                  |
+--------------------------------------------------+
|i14 : g = inducedMap(C'', C)                      |
|                                                  |
|           9                                 9    |
|o14 = 2 : R  <----------------------------- R  : 2|
|                {3} | 1 0 0 0 0 0 0 0 0 |         |
|                {3} | 0 1 0 0 0 0 0 0 0 |         |
|                {3} | 0 0 1 0 0 0 0 0 0 |         |
|                {3} | 0 0 0 1 0 0 0 0 0 |         |
|                {3} | 0 0 0 0 1 0 0 0 0 |         |
|                {3} | 0 0 0 0 0 1 0 0 0 |         |
|                {3} | 0 0 0 0 0 0 1 0 0 |         |
|                {3} | 0 0 0 0 0 0 0 1 0 |         |
|                {3} | 0 0 0 0 0 0 0 0 1 |         |
|                                                  |
|           5                         5            |
|      3 : R  <--------------------- R  : 3        |
|                {4} | 1 0 0 0 0 |                 |
|                {4} | 0 1 0 0 0 |                 |
|                {4} | 0 0 1 0 0 |                 |
|                {4} | 0 0 0 1 0 |                 |
|                {4} | 0 0 0 0 1 |                 |
|                                                  |
|           1                 1                    |
|      4 : R  <------------- R  : 4                |
|                {5} | 1 |                         |
|                                                  |
|o14 : ComplexMap                                  |
+--------------------------------------------------+
|i15 : assert isShortExactSequence(g,f)            |
+--------------------------------------------------+

There is another type of truncation, see canonicalTruncation,
which induces an isomorphism on (a
range) of homology.

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * naiveTruncation(ComplexMap,Sequence)
    -- drops all terms in the source
    of a complex outside a given interval
  * canonicalTruncation(Complex,ZZ,ZZ)
    -- reducing the number of
    non-zero terms of a complex
  * canonicalTruncation(ComplexMap,ZZ,ZZ)
    -- reducing the number of
    non-zero terms of a complex
  * truncate(List,Complex) -- truncation
    of a complex at a specified degree or set of degrees

Ways to use this method:
========================

  * "naiveTruncation(Complex,InfiniteNumber,InfiniteNumber)"
  * "naiveTruncation(Complex,InfiniteNumber,ZZ)"
  * "naiveTruncation(Complex,Nothing,ZZ)"
  * "naiveTruncation(Complex,Sequence)"
  * "naiveTruncation(Complex,ZZ,InfiniteNumber)"
  * "naiveTruncation(Complex,ZZ,Nothing)"
  * naiveTruncation(Complex,ZZ,ZZ)
    -- drops all terms of a complex
    outside a given interval

naiveTruncation(ComplexMap,ZZ,ZZ) -- drops all terms in the source of a complex outside a given interval
********************************************************************************************************

Synopsis
========

  * Function: naiveTruncation,
  * Usage:
        naiveTruncation(f, lo, hi)
        naiveTruncation(f, (lo, hi))
  * Inputs:
      * f, a map of complexes,
      * lo, an integer (Macaulay2Doc), or -infinity or null (the
        latter two give no lower bound)
      * hi, an integer (Macaulay2Doc), or infinity or null (the
        latter two give no upper bound)
  * Outputs:
      * a map of complexes,

Description
===========

Naive truncations of complexes are functorial.  Given a map of chain complexes,
this method returns the canonical map from the naive truncation of the source
to the naive truncation of the target.  The degree of f is used to determine
the appropriate naive truncation of the target complex.

First, we define some non-trivial maps of chain complexes.

+---------------------------------------------------------------------------+
|i1 : R = ZZ/101[a..d];                                                     |
+---------------------------------------------------------------------------+
|i2 : C = (freeResolution coker matrix{{a,b,c}})[1]                         |
|                                                                           |
|      1      3      3      1                                               |
|o2 = R  <-- R  <-- R  <-- R                                                |
|                                                                           |
|     -1     0      1      2                                                |
|                                                                           |
|o2 : Complex                                                               |
+---------------------------------------------------------------------------+
|i3 : D = freeResolution coker matrix{{a*b,a*c,b*c}}                        |
|                                                                           |
|      1      3      2                                                      |
|o3 = R  <-- R  <-- R                                                       |
|                                                                           |
|     0      1      2                                                       |
|                                                                           |
|o3 : Complex                                                               |
+---------------------------------------------------------------------------+
|i4 : E = freeResolution coker matrix{{a^2,b^2,c*d}}                        |
|                                                                           |
|      1      3      3      1                                               |
|o4 = R  <-- R  <-- R  <-- R                                                |
|                                                                           |
|     0      1      2      3                                                |
|                                                                           |
|o4 : Complex                                                               |
+---------------------------------------------------------------------------+
|i5 : f = randomComplexMap(D, C)                                            |
|                                                                           |
|                    1                                                      |
|o5 = -1 : 0 <----- R  : -1                                                 |
|               0                                                           |
|                                                                           |
|          1                                                           3    |
|     0 : R  <------------------------------------------------------- R  : 0|
|               | 24a-36b-30c-29d 19a+19b-10c-29d -8a-22b-29c-24d |         |
|                                                                           |
|          3                          3                                     |
|     1 : R  <---------------------- R  : 1                                 |
|               {2} | -38 21 -47 |                                          |
|               {2} | -16 34 -39 |                                          |
|               {2} | 39  19 -18 |                                          |
|                                                                           |
|          2                   1                                            |
|     2 : R  <--------------- R  : 2                                        |
|               {3} | -13 |                                                 |
|               {3} | -43 |                                                 |
|                                                                           |
|o5 : ComplexMap                                                            |
+---------------------------------------------------------------------------+
|i6 : g = randomComplexMap(E, D)                                            |
|                                                                           |
|          1               1                                                |
|o6 = 0 : R  <----------- R  : 0                                            |
|               | -15 |                                                     |
|                                                                           |
|          3                          3                                     |
|     1 : R  <---------------------- R  : 1                                 |
|               {2} | -28 2  45  |                                          |
|               {2} | -47 16 -34 |                                          |
|               {2} | 38  22 -48 |                                          |
|                                                                           |
|          3         2                                                      |
|     2 : R  <----- R  : 2                                                  |
|               0                                                           |
|                                                                           |
|o6 : ComplexMap                                                            |
+---------------------------------------------------------------------------+
|i7 : h = g * f                                                             |
|                                                                           |
|          1                                                           3    |
|o7 = 0 : R  <------------------------------------------------------- R  : 0|
|               | 44a+35b+46c+31d 18a+18b+49c+31d 19a+27b+31c-44d |         |
|                                                                           |
|          3                          3                                     |
|     1 : R  <---------------------- R  : 1                                 |
|               {2} | -41 32 24  |                                          |
|               {2} | 2   22 -25 |                                          |
|               {2} | -32 28 38  |                                          |
|                                                                           |
|o7 : ComplexMap                                                            |
+---------------------------------------------------------------------------+

We use these maps to illustrate naive truncation.

+----------------------------------------------------------------------------+
|i8 : tf = naiveTruncation(f, 0, 1)                                          |
|                                                                            |
|          1                                                           3     |
|o8 = 0 : R  <------------------------------------------------------- R  : 0 |
|               | 24a-36b-30c-29d 19a+19b-10c-29d -8a-22b-29c-24d |          |
|                                                                            |
|          3                          3                                      |
|     1 : R  <---------------------- R  : 1                                  |
|               {2} | -38 21 -47 |                                           |
|               {2} | -16 34 -39 |                                           |
|               {2} | 39  19 -18 |                                           |
|                                                                            |
|o8 : ComplexMap                                                             |
+----------------------------------------------------------------------------+
|i9 : tg = naiveTruncation(g, (0, 1))                                        |
|                                                                            |
|          1               1                                                 |
|o9 = 0 : R  <----------- R  : 0                                             |
|               | -15 |                                                      |
|                                                                            |
|          3                          3                                      |
|     1 : R  <---------------------- R  : 1                                  |
|               {2} | -28 2  45  |                                           |
|               {2} | -47 16 -34 |                                           |
|               {2} | 38  22 -48 |                                           |
|                                                                            |
|o9 : ComplexMap                                                             |
+----------------------------------------------------------------------------+
|i10 : th = naiveTruncation(h, (0, 1))                                       |
|                                                                            |
|           1                                                           3    |
|o10 = 0 : R  <------------------------------------------------------- R  : 0|
|                | 44a+35b+46c+31d 18a+18b+49c+31d 19a+27b+31c-44d |         |
|                                                                            |
|           3                          3                                     |
|      1 : R  <---------------------- R  : 1                                 |
|                {2} | -41 32 24  |                                          |
|                {2} | 2   22 -25 |                                          |
|                {2} | -32 28 38  |                                          |
|                                                                            |
|o10 : ComplexMap                                                            |
+----------------------------------------------------------------------------+
|i11 : assert all({tf, tg, th}, isWellDefined)                               |
+----------------------------------------------------------------------------+
|i12 : assert(th == tg * tf)                                                 |
+----------------------------------------------------------------------------+
+----------------------------------------------------------------------------+
|i13 : t2f = naiveTruncation(f, -infinity, 1)                                |
|                                                                            |
|           1                                                           3    |
|o13 = 0 : R  <------------------------------------------------------- R  : 0|
|                | 24a-36b-30c-29d 19a+19b-10c-29d -8a-22b-29c-24d |         |
|                                                                            |
|           3                          3                                     |
|      1 : R  <---------------------- R  : 1                                 |
|                {2} | -38 21 -47 |                                          |
|                {2} | -16 34 -39 |                                          |
|                {2} | 39  19 -18 |                                          |
|                                                                            |
|o13 : ComplexMap                                                            |
+----------------------------------------------------------------------------+
|i14 : assert(t2f == naiveTruncation(f,, 1))                                 |
+----------------------------------------------------------------------------+
|i15 : assert(tf != t2f)                                                     |
+----------------------------------------------------------------------------+

It is also possible to truncate the source and target independently.

+-----------------------------------------------------+
|i16 : t2f = naiveTruncation(f, (0,1), (1,2))         |
|                                                     |
|           3                          3              |
|o16 = 1 : R  <---------------------- R  : 1          |
|                {2} | -38 21 -47 |                   |
|                {2} | -16 34 -39 |                   |
|                {2} | 39  19 -18 |                   |
|                                                     |
|o16 : ComplexMap                                     |
+-----------------------------------------------------+
|i17 : assert(source t2f == naiveTruncation(C, (1,2)))|
+-----------------------------------------------------+
|i18 : assert(target t2f == naiveTruncation(D, (0,1)))|
+-----------------------------------------------------+

There is another type of truncation, see canonical truncation,
which induces an isomorphism on
(a range) of homology.

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * naiveTruncation(Complex,Sequence)
    -- drops all terms of a complex
    outside a given interval
  * canonicalTruncation(Complex,ZZ,ZZ)
    -- reducing the number of
    non-zero terms of a complex
  * canonicalTruncation(ComplexMap,ZZ,ZZ)
    -- reducing the number of
    non-zero terms of a complex
  * truncate(List,ComplexMap), --
    truncation of a complex map at a specified degree or set of degrees

Ways to use this method:
========================

  * "naiveTruncation(ComplexMap,InfiniteNumber,InfiniteNumber)"
  * "naiveTruncation(ComplexMap,InfiniteNumber,ZZ)"
  * "naiveTruncation(ComplexMap,Nothing,ZZ)"
  * "naiveTruncation(ComplexMap,Sequence)"
  * "naiveTruncation(ComplexMap,Sequence,Sequence)"
  * "naiveTruncation(ComplexMap,ZZ,InfiniteNumber)"
  * "naiveTruncation(ComplexMap,ZZ,Nothing)"
  * naiveTruncation(ComplexMap,ZZ,ZZ)
    -- drops all terms in the source
    of a complex outside a given interval

nullHomotopy(ComplexMap) -- a map which is a candidate for being a null homotopy
********************************************************************************

Synopsis
========

  * Function: nullHomotopy,
  * Usage:
        h = nullHomotopy f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * h, a map of complexes,

Description
===========

A map of chain complexes $f \colon C \to D$ is null-homotopic if there exists a
map of chain complexes $h : C \to D$ of degree $\deg(f)+1$, such that we have
the equality \[ f = \operatorname{dd}^D h + (-1)^{\deg(f)} h
\operatorname{dd}^C. \] Given $f$, this method returns a map $h$ of chain
complexes that will be a null-homotopy if one exists.

As a first example, we construct a map of chain complexes in which the null
homotopy is given by the identity.

+-------------------------------------------------------------------+
|i1 : R = ZZ/101[x,y,z];                                            |
+-------------------------------------------------------------------+
|i2 : M = cokernel matrix{{x,y,z^2}, {y^2,z,x^2}}                   |
|                                                                   |
|o2 = cokernel | x  y z2 |                                          |
|              | y2 z x2 |                                          |
|                                                                   |
|                            2                                      |
|o2 : R-module, quotient of R                                       |
+-------------------------------------------------------------------+
|i3 : C = complex {id_M}                                            |
|                                                                   |
|o3 = cokernel | x  y z2 | <-- cokernel | x  y z2 |                 |
|              | y2 z x2 |              | y2 z x2 |                 |
|                                                                   |
|     0                        1                                    |
|                                                                   |
|o3 : Complex                                                       |
+-------------------------------------------------------------------+
|i4 : assert isNullHomotopic id_C                                   |
+-------------------------------------------------------------------+
|i5 : h = nullHomotopy id_C                                         |
|                                                                   |
|o5 = 1 : cokernel | x  y z2 | <----------- cokernel | x  y z2 | : 0|
|                  | y2 z x2 |    | 1 0 |            | y2 z x2 |    |
|                                 | 0 1 |                           |
|                                                                   |
|     2 : 0 <----- cokernel | x  y z2 | : 1                         |
|              0            | y2 z x2 |                             |
|                                                                   |
|o5 : ComplexMap                                                    |
+-------------------------------------------------------------------+
|i6 : assert(h_0 == id_M)                                           |
+-------------------------------------------------------------------+
|i7 : assert isNullHomotopyOf(h, id_C)                              |
+-------------------------------------------------------------------+

A random map of chain complexes, arising as a boundary in the associated Hom
complex, is automatically null homotopic.

+-----------------------------------------------------------------------------+
|i8 : C = (freeResolution M) ** R^1/ideal(x^3, z^3-x)                         |
|                                                                             |
|o8 = cokernel | x3 z3-x 0  0    | <-- cokernel {2} | x3 z3-x 0  0    0  0    |
|              | 0  0    x3 z3-x |              {1} | 0  0    x3 z3-x 0  0    |
|                                               {2} | 0  0    0  0    x3 z3-x |
|     0                                                                       |
|                                      1                                      |
|                                                                             |
|o8 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|| <-- cokernel {5} | x3 z3-x 0  0    0  0    | <-- cokernel {7} | x3 z3-x 0  |
||              {7} | 0  0    x3 z3-x 0  0    |              {9} | 0  0    x3 |
||              {9} | 0  0    0  0    x3 z3-x |                               |
|                                                   3                         |
|      2                                                                      |
|-----------------------------------------------------------------------------|
|0    |                                                                       |
|z3-x |                                                                       |
+-----------------------------------------------------------------------------+
|i9 : f = randomComplexMap(C, C[1],                                           |
|                                                                             |
|o9 = -1 : 0 <----- cokernel | x3 z3                                          |
|               0            | 0  0                                           |
|                                                                             |
|     0 : cokernel | x3 z3-x 0  0                                             |
|                  | 0  0    x3 z3-x                                          |
|                                                                             |
|                                                                             |
|     1 : cokernel {2} | x3 z3-x 0                                            |
|                  {1} | 0  0    x3                                           |
|                  {2} | 0  0    0                                            |
|                                                                             |
|                                                                             |
|     2 : cokernel {5} | x3 z3-x 0                                            |
|                  {7} | 0  0    x3                                           |
|                  {9} | 0  0    0                                            |
|                                                                             |
|                                                                             |
|o9 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|Boundary => true)                                                            |
|                                                                             |
|-x 0  0    | : -1                                                            |
|   x3 z3-x |                                                                 |
|                                                                             |
| | <-------------------------------------------------------------------------|
| |    | 19xy+20y2-29yz-8z2-5x        -46y+30z 30x2-24xy-38y2-16yz+15z2-29x | |
|      | -8x2+48y2+19xz-10yz-29z2+36x 36y+7z   -33x2-29y2-24xz-38yz+20z2    | |
|                                                                             |
|0    0  0    | <-------------------------------------------------------------|
|z3-x 0  0    |    {2} | 2x2y-29y3+29xz-2x                                    |
|0    x3 z3-x |    {1} | 10x2y2-24xy3-38y4+29x2yz-16y3z+43y2z2+24x2z+38xyz+16x|
|                  {2} | 8x2y+18y3-18xz-8x                                    |
|                                                                             |
|0    0  0    | <-------------------------------------------------------------|
|z3-x 0  0    |    {5} | 21x2-34xy+47y2-19xz+39yz+18z2 -19x2y2+43xy3+47y4+16x2|
|0    x3 z3-x |    {7} | 13                            -16x2-22xy-48y2-45xz+32|
|                  {9} | 0                             -47                    |
|-----------------------------------------------------------------------------|
|- cokernel {2} | x3 z3-x 0  0    0  0    | : 0                               |
|           {1} | 0  0    x3 z3-x 0  0    |                                   |
|           {2} | 0  0    0  0    x3 z3-x |                                   |
|                                                                             |
|-----------------------------------------------------------------------------|
|                  25x2y3-39x2y2z-18x2yz2-34x2y+47xy2-19x2z+39xyz+18xz2       |
|z2+19x2-10xy-29xz -38x2y4-16x2y3z+9x2y2z2+34xy3z2-47y4z2+19x2y2-39xy3-18xy2z |
|                  -49x2y3-34xy4+47y5-19xy3z+39y4z+18y3z2+34x2yz-47xy2z+19x2z2|
|                                                                             |
|-------------------------------------- cokernel {7} | x3 z3-x 0  0    | : 2  |
|yz+15xy2z-38y3z-7x2z2+28xyz2-2y2z2 |            {9} | 0  0    x3 z3-x |      |
|yz-47z2                            |                                         |
|                                   |                                         |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
|             -47x2y5+38x2y4z+2x2y3z2+43x2y3+47xy4+15x2y2z-38xy3z+28x2yz2-2xy2|
|             -34x2y4z2-43xy5z2-47y6z2-15x2y4+38xy5-28x2y3z+2xy4z             |
|-39xyz2-18x2 34x2y5+43xy6+47y7+48x2y4z+15xy5z-38y6z+47x2y3z2+28xy4z2-2y5z2-43|
|-----------------------------------------------------------------------------|
|--------------------------------------- cokernel {5} | x3 z3-x 0  0    0     |
|z2                                  |            {7} | 0  0    x3 z3-x 0     |
|                                    |            {9} | 0  0    0  0    x3    |
|x2y3z-47xy4z-15x2y2z2+38xy3z2+2x2y2 |                                        |
|-----------------------------------------------------------------------------|
|0    | : 1                                                                   |
|0    |                                                                       |
|z3-x |                                                                       |
+-----------------------------------------------------------------------------+
|i10 : assert isNullHomotopic f                                               |
+-----------------------------------------------------------------------------+
|i11 : h = nullHomotopy f                                                     |
|                                                                             |
|o11 = 0 : cokernel | x3 z3-x 0  0    |                                       |
|                   | 0  0    x3 z3-x |                                       |
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | x3 z3-x 0  0                                        |
|                   {1} | 0  0    x3 z3-                                      |
|                   {2} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      2 : cokernel {5} | x3 z3-x 0  0                                        |
|                   {7} | 0  0    x3 z3-                                      |
|                   {9} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      3 : cokernel {7} | x3 z3-x 0  0                                        |
|                   {9} | 0  0    x3 z3-                                      |
|                                                                             |
|                                                                             |
|o11 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|<----------------------------------- cokernel | x3 z3-x 0  0    | : -1       |
|   | 24yz+46        -24y2-30     |            | 0  0    x3 z3-x |            |
|   | -2x2yz+24z2-36 2x2y2-24yz-7 |                                           |
|                                                                             |
|  0  0    | <--------------------------------------------------- cokernel {2}|
|x 0  0    |    {2} | 2x2y2+41               0 -29            |            {1}|
|  x3 z3-x |    {1} | -24y3+24xz+19x-10y-29z 0 -24x2y-38y-16z |            {2}|
|               {2} | -8                     0 -40            |               |
|                                                                             |
|  0  0    | <----------------------------------------------------------------|
|x 0  0    |    {5} | 43 9x2+34xy-47y2+19xz-39yz-18z2 -34x2y2-43xy3-47y4-48x2y|
|  x3 z3-x |    {7} | 0  0                            0                       |
|               {9} | 0  0                            47                      |
|                                                                             |
|  | <--------------------------------------------- cokernel {7} | x3 z3-x 0  |
|x |    {7} | 13 -16x2-22xy-48y2-45xz+32yz-47z2 |            {9} | 0  0    x3 |
|       {9} | 0  0                              |                             |
|-----------------------------------------------------------------------------|
| | x3 z3-x 0  0    0  0    | : 0                                             |
| | 0  0    x3 z3-x 0  0    |                                                 |
| | 0  0    0  0    x3 z3-x |                                                 |
|                                                                             |
|                                                                             |
|-------------------------------------- cokernel {5} | x3 z3-x 0  0    0  0   |
|z-15xy2z+38y3z-47x2z2-28xyz2+2y2z2 |            {7} | 0  0    x3 z3-x 0  0   |
|                                   |            {9} | 0  0    0  0    x3 z3-x|
|                                   |                                         |
|                                                                             |
|0    | : 2                                                                   |
|z3-x |                                                                       |
|-----------------------------------------------------------------------------|
|| : 1                                                                        |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i12 : assert isNullHomotopyOf(h, f)                                          |
+-----------------------------------------------------------------------------+

When a map of chain complexes is not null-homotopic, this method nevertheless
returns a map $h$ of chain complexes, having the correct source, target and
degree, but cannot be a null homotopy.

+-----------------------------------------------------------------------------+
|i13 : g = randomComplexMap(C, C[1])                                          |
|                                                                             |
|o13 = -1 : 0 <----- cokernel | x3 z3-x                                       |
|                0            | 0  0                                          |
|                                                                             |
|      0 : cokernel | x3 z3-x 0  0    |                                       |
|                   | 0  0    x3 z3-x |                                       |
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | x3 z3-x 0  0                                        |
|                   {1} | 0  0    x3 z3-                                      |
|                   {2} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      2 : cokernel {5} | x3 z3-x 0  0                                        |
|                   {7} | 0  0    x3 z3-                                      |
|                   {9} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|0  0    | : -1                                                               |
|x3 z3-x |                                                                    |
|                                                                             |
|<----------------------------------------------------------------------------|
|   | 15x2-23xy+43y2+39xz-17yz-11z2 40x+11y+46z 22x2-47xy-7y2-23xz+2yz+29z2   |
|   | 48x2+36xy+11y2+35xz-38yz+33z2 -28x+y-3z   -47x2+15xy-13y2-37xz-10yz+30z2|
|                                                                             |
|  0  0    | <----------------------------------------------------------------|
|x 0  0    |    {2} | -18x2y+27xy2-9y3+39x2z-22xyz-32y2z+32xz2-20yz2      4x2y|
|  x3 z3-x |    {1} | 24x2y2-15xy3+33y4-30x2yz+39xy2z-49y3z-48x2z2-33y2z2 36x2|
|               {2} | -19x2y-20xy2+36y3+17x2z+44xyz+9y2z-39xz2-39yz2      -9x2|
|                                                                             |
|  0  0    | <----------------------------------------------------------------|
|x 0  0    |    {5} | 30x2+13xy-13y2-17xz+3yz-41z2 8x2y2-46xy3+42y4-29x2yz+49x|
|  x3 z3-x |    {7} | 8                            15x2+18xy-46y2-16xz+12yz-18|
|               {9} | 0                            27                         |
|-----------------------------------------------------------------------------|
|---- cokernel {2} | x3 z3-x 0  0    0  0    | : 0                            |
| |            {1} | 0  0    x3 z3-x 0  0    |                                |
| |            {2} | 0  0    0  0    x3 z3-x |                                |
|                                                                             |
|-----------------------------------------------------------------------------|
|3+22xy4-8y5+13x2y2z-49xy3z+43y4z-26x2yz2-11xy2z2-8y3z2   -49x2y5+30xy6-40y7-1|
|y4-30xy5-28y6-3x2y3z+41xy4z-6y5z-22x2y2z2+16xy3z2+35y4z2 -31x2y6-48xy7+30y8-3|
|y3+40xy4+25y5-35x2y2z+3xy3z-2y4z+6x2yz2-31xy2z2-41y3z2   -49x2y5+46xy6-22y7+2|
|                                                                             |
|---------------------------------- cokernel {7} | x3 z3-x 0  0    | : 2      |
|y2z+23y3z+30x2z2-18xyz2-28y2z2 |            {9} | 0  0    x3 z3-x |          |
|z2                             |                                             |
|                               |                                             |
|-----------------------------------------------------------------------------|
|----------------------------------------------- cokernel {5} | x3 z3-x 0     |
|3x2y4z-47xy5z+37y6z+4x2y3z2+27xy4z2-35y5z2  |            {7} | 0  0    x3    |
|9x2y5z-29xy6z-37y7z-31x2y4z2-48xy5z2+47y6z2 |            {9} | 0  0    0     |
|8x2y4z+xy5z+10y6z-18x2y3z2+40xy4z2+7y5z2    |                                |
|-----------------------------------------------------------------------------|
|0    0  0    | : 1                                                           |
|z3-x 0  0    |                                                               |
|0    x3 z3-x |                                                               |
+-----------------------------------------------------------------------------+
|i14 : assert not isNullHomotopic g                                           |
+-----------------------------------------------------------------------------+
|i15 : h' = nullHomotopy g                                                    |
|                                                                             |
|o15 = 0 : cokernel | x3 z3-x 0  0    |                                       |
|                   | 0  0    x3 z3-x |                                       |
|                                                                             |
|                                                                             |
|      1 : cokernel {2} | x3 z3-x 0  0                                        |
|                   {1} | 0  0    x3 z3-                                      |
|                   {2} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      2 : cokernel {5} | x3 z3-x 0  0                                        |
|                   {7} | 0  0    x3 z3-                                      |
|                   {9} | 0  0    0  0                                        |
|                                                                             |
|                                                                             |
|      3 : cokernel {7} | x3 z3-x 0  0                                        |
|                   {9} | 0  0    x3 z3-                                      |
|                                                                             |
|                                                                             |
|o15 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|<----------------------------------------------------------------------------|
|   | -39xyz2-36xz2+39xz-22yz-39z2-8z+41                       -23xy2z-29xyz-4|
|   | 18x2yz-27xy2z-39x2z2+22xyz2-48x2y+31xz2+18xz-27yz-35z-33 -18x2y2+27xy3+3|
|                                                                             |
|  0  0    | <----------------------------------------------------------------|
|x 0  0    |    {2} | -18x2y2+27xy3+39x2yz-22xy2z-7xyz2-31xyz-36xz2+48yz2+20x2|
|  x3 z3-x |    {1} | -23xy3z-27x2y2+22x2yz-29xy2z-48y3z-32x2z2-3xyz2-44x2y-39|
|               {2} | 17x2yz+44xy2z-39xyz2+3xy2+2xyz-20y2+17xz+44yz-39z2+3y+2z|
|                                                                             |
|  0  0    | <----------------------------------------------------------------|
|x 0  0    |    {5} | -39xyz2-36xz2+48yz2+30z2-33 48x2yz2+30x2z2-22x2+16xy+35y|
|  x3 z3-x |    {7} | 0                           0                           |
|               {9} | 0                           0                           |
|                                                                             |
|  | <------------------------------------------------- cokernel {7} | x3 z3-x|
|x |    {7} | -41 15x2+18xy+23y2-16xz-44yz-48z2+48z |            {9} | 0  0   |
|       {9} | 0   0                                 |                         |
|-----------------------------------------------------------------------------|
|------------------------------------------------------------- cokernel | x3 z|
|8y2z-39xy-15y2+9yz-20z2+36z+40                            |            | 0  0|
|9x2yz-22xy2z-30xyz2-31xyz+36xz2-18xy+27y2-37yz-30z2-31z-2 |                  |
|                                                                             |
|-----------------------------------------------------------------------------|
|-18xy+27y2+39xz-22yz-39z2-31z-33                        0                   -|
|xy2-15y3-31x2z+9y2z-48xz2+16x2-27xy+36yz-3z2+38y+30z-27 0                   -|
|-34                                                     39xy2+36xy-48y2-30y -|
|                                                                             |
|-----------------------------------------------------------------------------|
|2-3xz+13yz-26z2 -31x2y2-48xy3+47y4-28x2yz-xy2z-13y3z+18x2z2-40xyz2+4y2z2-48x2|
|                0                                                            |
|                -27                                                          |
|                                                                             |
| 0  0    | : 2                                                               |
| x3 z3-x |                                                                   |
|-----------------------------------------------------------------------------|
|3-x 0  0    | : -1                                                           |
|    x3 z3-x |                                                                |
|                                                                             |
|                                                                             |
|----------------------------- cokernel {2} | x3 z3-x 0  0    0  0    | : 0   |
|31                        |            {1} | 0  0    x3 z3-x 0  0    |       |
|48x2yz-15x2y-30x2z+36y-3z |            {2} | 0  0    0  0    x3 z3-x |       |
|20x2-31                   |                                                  |
|                                                                             |
|----------------------------- cokernel {5} | x3 z3-x 0  0    0  0    | : 1   |
|z+47xyz-13xz2-yz-40z2+47z |            {7} | 0  0    x3 z3-x 0  0    |       |
|                          |            {9} | 0  0    0  0    x3 z3-x |       |
|                          |                                                  |
+-----------------------------------------------------------------------------+
|i16 : assert isWellDefined h'                                                |
+-----------------------------------------------------------------------------+
|i17 : assert(degree h' === degree g + 1)                                     |
+-----------------------------------------------------------------------------+
|i18 : assert not isNullHomotopyOf(h', g)                                     |
+-----------------------------------------------------------------------------+

For developers: when the source of $f$ is a free complex, a procedure, that is
often faster, is attempted.  In the general case this method uses the Hom
complex.

Caveat
======

The output is only a null homotopy when one exists.

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * isNullHomotopic(ComplexMap), --
    whether a map of complexes is null-homotopic
  * isNullHomotopyOf(ComplexMap,ComplexMap)
    -- whether the first map of
    chain complexes is a null homotopy for the second
  * randomComplexMap -- a
    random map of chain complexes
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes

Ways to use this method:
========================

  * nullHomotopy(ComplexMap) -- a map
    which is a candidate for being a null homotopy

part(List,Complex) -- extract a graded component of a complex
*************************************************************

Synopsis
========

  * Function: part (Macaulay2Doc),
  * Usage:
        part(d, C)
  * Inputs:
      * d, a list (Macaulay2Doc), or ZZ (Macaulay2Doc),
        if the underlying ring $R$ is singly graded.
      * C, a complex, that is homogeneous over $R$
  * Outputs:
      * a complex, a complex over the coefficient ring of $R$

Description
===========

If $C$ is a graded (homogeneous) complex over a ring $R$, and $d$ is a degree,
this method computes the degree $d$ part of the complex over the coefficient
ring of $R$.

Taking parts of a graded (homogeneous) complex commutes with taking homology.

+------------------------------------------+
|i1 : R = QQ[a,b,c,d];                     |
+------------------------------------------+
|i2 : I = ideal(a*b, a*c, b*c, a*d)        |
|                                          |
|o2 = ideal (a*b, a*c, b*c, a*d)           |
|                                          |
|o2 : Ideal of R                           |
+------------------------------------------+
|i3 : C = freeResolution I                 |
|                                          |
|      1      4      4      1              |
|o3 = R  <-- R  <-- R  <-- R               |
|                                          |
|     0      1      2      3               |
|                                          |
|o3 : Complex                              |
+------------------------------------------+
|i4 : D = part(4,C)                        |
|                                          |
|       35       40       16       1       |
|o4 = QQ   <-- QQ   <-- QQ   <-- QQ        |
|                                          |
|     0        1        2        3         |
|                                          |
|o4 : Complex                              |
+------------------------------------------+
|i5 : prune HH D == part(4, HH C)          |
|                                          |
|o5 = true                                 |
+------------------------------------------+
|i6 : prune HH D == part(4, complex(R^1/I))|
|                                          |
|o6 = true                                 |
+------------------------------------------+

Given a squarefree monomial ideal corresponding to a simplicial complex, in a
polynomial ring equipped with the fine grading, parts of the dual of the free
resolution of the monomial ideal are the chain complexes of the induced
simplicial subcomplexes.

+--------------------------------------------------------------+
|i7 : S = QQ[a..d, DegreeRank=>4];                             |
+--------------------------------------------------------------+
|i8 : I = intersect(ideal(a,b), ideal(c,d))                    |
|                                                              |
|o8 = ideal (b*d, a*d, b*c, a*c)                               |
|                                                              |
|o8 : Ideal of S                                               |
+--------------------------------------------------------------+
|i9 : C = dual freeResolution I                                |
|                                                              |
|      1      4      4      1                                  |
|o9 = S  <-- S  <-- S  <-- S                                   |
|                                                              |
|     -3     -2     -1     0                                   |
|                                                              |
|o9 : Complex                                                  |
+--------------------------------------------------------------+
|i10 : prune HH (part({-1,-1,-1,-1}, C)) -- empty quadrilateral|
|                                                              |
|        1                                                     |
|o10 = QQ                                                      |
|                                                              |
|      -3                                                      |
|                                                              |
|o10 : Complex                                                 |
+--------------------------------------------------------------+
|i11 : prune HH part({-1,-1,0,0}, C) -- 2 points               |
|                                                              |
|        1                                                     |
|o11 = QQ                                                      |
|                                                              |
|      -2                                                      |
|                                                              |
|o11 : Complex                                                 |
+--------------------------------------------------------------+
|i12 : prune HH part({0,0,-1,-1}, C) -- 2 points               |
|                                                              |
|        1                                                     |
|o12 = QQ                                                      |
|                                                              |
|      -2                                                      |
|                                                              |
|o12 : Complex                                                 |
+--------------------------------------------------------------+
|i13 : prune HH part({0,0,0,0}, C) -- solid quadrilateral      |
|                                                              |
|o13 = 0                                                       |
|                                                              |
|      0                                                       |
|                                                              |
|o13 : Complex                                                 |
+--------------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * part(List,ComplexMap) -- extract a
    graded component of a map of complexes
  * truncate(List,Complex) -- truncation
    of a complex at a specified degree or set of degrees
  * truncate(List,ComplexMap), --
    truncation of a complex map at a specified degree or set of degrees
  * canonicalTruncation(Complex,Sequence)
    -- reducing the number of
    non-zero terms of a complex
  * naiveTruncation(Complex,ZZ,ZZ)
    -- drops all terms of a complex
    outside a given interval

Ways to use this method:
========================

  * part(List,Complex) -- extract a graded
    component of a complex
  * "part(ZZ,Complex)"

part(List,ComplexMap) -- extract a graded component of a map of complexes
*************************************************************************

Synopsis
========

  * Function: part (Macaulay2Doc),
  * Usage:
        part(d, f)
  * Inputs:
      * d, a list (Macaulay2Doc), or ZZ (Macaulay2Doc),
        if the underlying ring $R$ is singly graded.
      * f, a map of complexes, that is homogeneous over $R$
  * Outputs:
      * a map of complexes, a complex map over the
        coefficient ring of $R$

Description
===========

If $f$ is a graded (homogeneous) map of complexes over a ring $R$, and $d$ is a
degree, this method computes the degree $d$ part of the complex map over the
coefficient ring of $R$.

Taking parts of a graded (homogeneous) complex commutes with taking homology.

+--------------------------------------------------------------------+
|i1 : kk = ZZ/7                                                      |
|                                                                    |
|o1 = kk                                                             |
|                                                                    |
|o1 : QuotientRing                                                   |
+--------------------------------------------------------------------+
|i2 : R = kk[a,b,c,d];                                               |
+--------------------------------------------------------------------+
|i3 : I = ideal(a*b, a*c, b*c, a*d)                                  |
|                                                                    |
|o3 = ideal (a*b, a*c, b*c, a*d)                                     |
|                                                                    |
|o3 : Ideal of R                                                     |
+--------------------------------------------------------------------+
|i4 : J = I + ideal(b^3)                                             |
|                                                                    |
|                                 3                                  |
|o4 = ideal (a*b, a*c, b*c, a*d, b )                                 |
|                                                                    |
|o4 : Ideal of R                                                     |
+--------------------------------------------------------------------+
|i5 : C = freeResolution I                                           |
|                                                                    |
|      1      4      4      1                                        |
|o5 = R  <-- R  <-- R  <-- R                                         |
|                                                                    |
|     0      1      2      3                                         |
|                                                                    |
|o5 : Complex                                                        |
+--------------------------------------------------------------------+
|i6 : D = freeResolution ((R^1/J) ** R^{{1}})                        |
|                                                                    |
|      1      5      6      2                                        |
|o6 = R  <-- R  <-- R  <-- R                                         |
|                                                                    |
|     0      1      2      3                                         |
|                                                                    |
|o6 : Complex                                                        |
+--------------------------------------------------------------------+
|i7 : f = randomComplexMap(D,C, Cycle=>true)                         |
|                                                                    |
|          1                         1                               |
|o7 = 0 : R  <--------------------- R  : 0                           |
|               {-1} | 3a-3c+2d |                                    |
|                                                                    |
|          5                                                  4      |
|     1 : R  <---------------------------------------------- R  : 1  |
|               {1} | 3a+c-3d -d       -3d       2c+d    |           |
|               {1} | 3b+3d   3a-2b-3c -2b+3d    2b-3d   |           |
|               {1} | 0       2a       -2a-3c+2d 3a      |           |
|               {1} | -2b-3c  b+2c     3b-3c     3a-b+2d |           |
|               {2} | 0       0        0         0       |           |
|                                                                    |
|          6                                                    4    |
|     2 : R  <------------------------------------------------ R  : 2|
|               {2} | 3a+c+3d 0            -2b       -2c   |         |
|               {2} | 2b      -2a-2b-3c+2d 3b        3c-2d |         |
|               {2} | b+c     3a-b         3a-b+c-3d -c-d  |         |
|               {2} | 3b+3c   -3a-2b       -b+3d     3a    |         |
|               {3} | 0       0            0         0     |         |
|               {3} | 0       0            0         0     |         |
|                                                                    |
|          2                       1                                 |
|     3 : R  <------------------- R  : 3                             |
|               {3} | 3a+c+3d |                                      |
|               {4} | 0       |                                      |
|                                                                    |
|o7 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i8 : g = part(2,f)                                                  |
|                                                                    |
|           20                                          10           |
|o8 = 0 : kk   <------------------------------------- kk   : 0       |
|                 | 3  0  0  0  0  0  0  0  0  0  |                  |
|                 | 0  3  0  0  0  0  0  0  0  0  |                  |
|                 | -3 0  3  0  0  0  0  0  0  0  |                  |
|                 | 2  0  0  3  0  0  0  0  0  0  |                  |
|                 | 0  0  0  0  3  0  0  0  0  0  |                  |
|                 | 0  -3 0  0  0  3  0  0  0  0  |                  |
|                 | 0  2  0  0  0  0  3  0  0  0  |                  |
|                 | 0  0  -3 0  0  0  0  3  0  0  |                  |
|                 | 0  0  2  -3 0  0  0  0  3  0  |                  |
|                 | 0  0  0  2  0  0  0  0  0  3  |                  |
|                 | 0  0  0  0  0  0  0  0  0  0  |                  |
|                 | 0  0  0  0  -3 0  0  0  0  0  |                  |
|                 | 0  0  0  0  2  0  0  0  0  0  |                  |
|                 | 0  0  0  0  0  -3 0  0  0  0  |                  |
|                 | 0  0  0  0  0  2  -3 0  0  0  |                  |
|                 | 0  0  0  0  0  0  2  0  0  0  |                  |
|                 | 0  0  0  0  0  0  0  -3 0  0  |                  |
|                 | 0  0  0  0  0  0  0  2  -3 0  |                  |
|                 | 0  0  0  0  0  0  0  0  2  -3 |                  |
|                 | 0  0  0  0  0  0  0  0  0  2  |                  |
|                                                                    |
|           17                        4                              |
|     1 : kk   <------------------- kk  : 1                          |
|                 | 3  0  0  0  |                                    |
|                 | 0  0  0  0  |                                    |
|                 | 1  0  0  2  |                                    |
|                 | -3 -1 -3 1  |                                    |
|                 | 0  3  0  0  |                                    |
|                 | 3  -2 -2 2  |                                    |
|                 | 0  -3 0  0  |                                    |
|                 | 3  0  3  -3 |                                    |
|                 | 0  2  -2 3  |                                    |
|                 | 0  0  0  0  |                                    |
|                 | 0  0  -3 0  |                                    |
|                 | 0  0  2  0  |                                    |
|                 | 0  0  0  3  |                                    |
|                 | -2 1  3  -1 |                                    |
|                 | -3 2  -3 0  |                                    |
|                 | 0  0  0  2  |                                    |
|                 | 0  0  0  0  |                                    |
|                                                                    |
|o8 : ComplexMap                                                     |
+--------------------------------------------------------------------+
|i9 : assert(part(2, HH f) ==  prune HH part(2, f))                  |
+--------------------------------------------------------------------+

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * part(List,Complex) -- extract a graded
    component of a complex
  * truncate(List,Complex) -- truncation
    of a complex at a specified degree or set of degrees
  * truncate(List,ComplexMap), --
    truncation of a complex map at a specified degree or set of degrees
  * naiveTruncation(Complex,Sequence)
    -- drops all terms of a complex
    outside a given interval
  * canonicalTruncation(Complex,ZZ,ZZ)
    -- reducing the number of
    non-zero terms of a complex

Ways to use this method:
========================

  * part(List,ComplexMap) -- extract a
    graded component of a map of complexes
  * "part(ZZ,ComplexMap)"

poincare(Complex) -- assemble degrees of a chain complex into a polynomial
**************************************************************************

Synopsis
========

  * Function: poincare (Macaulay2Doc),
  * Usage:
        poincare C
  * Inputs:
      * C, a complex,
  * Outputs:
      * a ring element (Macaulay2Doc), in the ring of degrees (Macaulay2Doc),
        of the underlying ring of $C$

Description
===========

This method encodes information about the degrees of the generators of each
term in a chain complex. It returns an element in the degrees ring, which is
the ring of Laurent polynomials whose monomials correspond to the degrees of
the monomials in the underlying ring of $C$. When the $i$-th term $C_i$ of the
complex $C$ is generated by elements of degree $d_{i,1}, d_{i,2}, \dotsc$, this
Laurent polynomial is $\sum_i (-1)^i \sum_j T^{d_{i,j}}$, where we use
multi-index notation $T^d = T_0^{d_0} T_1^{d_1} \dotsb T_r^{d_r}$.

+----------------------------------------------------+
|i1 : R = ZZ/32003[a..f];                            |
+----------------------------------------------------+
|i2 : K = koszulComplex vars R                       |
|                                                    |
|      1      6      15      20      15      6      1|
|o2 = R  <-- R  <-- R   <-- R   <-- R   <-- R  <-- R |
|                                                    |
|     0      1      2       3       4       5      6 |
|                                                    |
|o2 : Complex                                        |
+----------------------------------------------------+
|i3 : betti K                                        |
|                                                    |
|            0 1  2  3  4 5 6                        |
|o3 = total: 1 6 15 20 15 6 1                        |
|         0: 1 6 15 20 15 6 1                        |
|                                                    |
|o3 : BettiTally                                     |
+----------------------------------------------------+
|i4 : p = poincare K                                 |
|                                                    |
|                 2      3      4     5    6         |
|o4 = 1 - 6T + 15T  - 20T  + 15T  - 6T  + T          |
|                                                    |
|o4 : ZZ[T]                                          |
+----------------------------------------------------+
|i5 : factor p                                       |
|                                                    |
|            6                                       |
|o5 = (1 - T)                                        |
|                                                    |
|o5 : Expression of class Product                    |
+----------------------------------------------------+
+--------------------------------------------------+
|i6 : C = freeResolution ideal(a*b, b*c*d, c*d*e^2)|
|                                                  |
|      1      3      2                             |
|o6 = R  <-- R  <-- R                              |
|                                                  |
|     0      1      2                              |
|                                                  |
|o6 : Complex                                      |
+--------------------------------------------------+
|i7 : betti C                                      |
|                                                  |
|            0 1 2                                 |
|o7 = total: 1 3 2                                 |
|         0: 1 . .                                 |
|         1: . 1 .                                 |
|         2: . 1 1                                 |
|         3: . 1 1                                 |
|                                                  |
|o7 : BettiTally                                   |
+--------------------------------------------------+
|i8 : poincare C                                   |
|                                                  |
|          2    3    5                             |
|o8 = 1 - T  - T  + T                              |
|                                                  |
|o8 : ZZ[T]                                        |
+--------------------------------------------------+

Since the number of variables in the degrees ring is equal to the rank of the
grading group, the Poincare polynomial may have more than one variable.

+----------------------------------------------------+
|i9 : S = ZZ/101[x,y,z, DegreeRank => 3];            |
+----------------------------------------------------+
|i10 : L = koszulComplex vars S                      |
|                                                    |
|       1      3      3      1                       |
|o10 = S  <-- S  <-- S  <-- S                        |
|                                                    |
|      0      1      2      3                        |
|                                                    |
|o10 : Complex                                       |
+----------------------------------------------------+
|i11 : poincare L                                    |
|                                                    |
|o11 = 1 - T  - T  - T  + T T  + T T  + T T  - T T T |
|           0    1    2    0 1    0 2    1 2    0 1 2|
|                                                    |
|o11 : ZZ[T ..T ]                                    |
|          0   2                                     |
+----------------------------------------------------+

If the terms in the complex are not free, then this method uses just the
degrees of the generators of each term.

+-----------------------------------------------------------------------------+
|i12 : D = C ** coker vars R                                                  |
|                                                                             |
|o12 = cokernel | a b c d e f | <-- cokernel {2} | a b c d e f 0 0 0 0 0 0 0 0|
|                                            {3} | 0 0 0 0 0 0 a b c d e f 0 0|
|      0                                     {4} | 0 0 0 0 0 0 0 0 0 0 0 0 a b|
|                                                                             |
|                                   1                                         |
|                                                                             |
|o12 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0 0 0 0 | <-- cokernel {4} | a b c d e f 0 0 0 0 0 0 |                       |
|0 0 0 0 |              {5} | 0 0 0 0 0 0 a b c d e f |                       |
|c d e f |                                                                    |
|              2                                                              |
+-----------------------------------------------------------------------------+
|i13 : poincare D                                                             |
|                                                                             |
|           2    3    5                                                       |
|o13 = 1 - T  - T  + T                                                        |
|                                                                             |
|o13 : ZZ[T]                                                                  |
+-----------------------------------------------------------------------------+
|i14 : betti D                                                                |
|                                                                             |
|             0 1 2                                                           |
|o14 = total: 1 3 2                                                           |
|          0: 1 . .                                                           |
|          1: . 1 .                                                           |
|          2: . 1 1                                                           |
|          3: . 1 1                                                           |
|                                                                             |
|o14 : BettiTally                                                             |
+-----------------------------------------------------------------------------+

This is equivalent to computing the Poincare polynomial of the Betti table.

+----------------------+
|i15 : poincare betti D|
|                      |
|           2    3    5|
|o15 = 1 - T  - T  + T |
|                      |
|o15 : ZZ[T]           |
+----------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * poincare (Macaulay2Doc) -- assemble degrees of a ring,
    module, or ideal into a polynomial
  * poincareN(Complex) -- assemble degrees of a
    chain complex into a polynomial
  * betti (Macaulay2Doc) -- display or modify a Betti diagram

Ways to use this method:
========================

  * poincare(Complex) -- assemble degrees of a
    chain complex into a polynomial

poincareN(Complex) -- assemble degrees of a chain complex into a polynomial
***************************************************************************

Synopsis
========

  * Function: poincareN (Macaulay2Doc),
  * Usage:
        poincareN C
  * Inputs:
      * C, a complex,
  * Outputs:
      * a ring element (Macaulay2Doc),

Description
===========

This method encodes information about the internal and homological degrees of
the generators of each term in a chain complex. It returns an element in the
ring of Laurent polynomials whose monomials correspond to the degrees of the
monomials in the underlying ring of $C$, together with a variable to record the
homological degree. When the $i$-th term $C_i$ of the complex $C$ is generated
by elements of degree $d_{i,1}, d_{i,2}, \dotsc$, this Laurent polynomial is
$\sum_i (-1)^i \sum_j S^i T^{d_{i,j}}$, where we use multi-index notation $T^d
= T_0^{d_0} T_1^{d_1} \dotsb T_r^{d_r}$.

+--------------------------------------------------------+
|i1 : R = ZZ/32003[a..f];                                |
+--------------------------------------------------------+
|i2 : K = koszulComplex vars R                           |
|                                                        |
|      1      6      15      20      15      6      1    |
|o2 = R  <-- R  <-- R   <-- R   <-- R   <-- R  <-- R     |
|                                                        |
|     0      1      2       3       4       5      6     |
|                                                        |
|o2 : Complex                                            |
+--------------------------------------------------------+
|i3 : betti K                                            |
|                                                        |
|            0 1  2  3  4 5 6                            |
|o3 = total: 1 6 15 20 15 6 1                            |
|         0: 1 6 15 20 15 6 1                            |
|                                                        |
|o3 : BettiTally                                         |
+--------------------------------------------------------+
|i4 : p = poincareN K                                    |
|                                                        |
|                    2 2      3 3      4 4     5 5    6 6|
|o4 = 1 + 6S*T  + 15S T  + 20S T  + 15S T  + 6S T  + S T |
|             0        0        0        0       0      0|
|                                                        |
|o4 : ZZ[S, T ]                                          |
|            0                                           |
+--------------------------------------------------------+
|i5 : factor p                                           |
|                                                        |
|               6                                        |
|o5 = (1 + S*T )                                         |
|             0                                          |
|                                                        |
|o5 : Expression of class Product                        |
+--------------------------------------------------------+
+--------------------------------------------------+
|i6 : C = freeResolution ideal(a*b, b*c*d, c*d*e^2)|
|                                                  |
|      1      3      2                             |
|o6 = R  <-- R  <-- R                              |
|                                                  |
|     0      1      2                              |
|                                                  |
|o6 : Complex                                      |
+--------------------------------------------------+
|i7 : betti C                                      |
|                                                  |
|            0 1 2                                 |
|o7 = total: 1 3 2                                 |
|         0: 1 . .                                 |
|         1: . 1 .                                 |
|         2: . 1 1                                 |
|         3: . 1 1                                 |
|                                                  |
|o7 : BettiTally                                   |
+--------------------------------------------------+
|i8 : poincareN C                                  |
|                                                  |
|            2      3      4    2 4    2 5         |
|o8 = 1 + S*T  + S*T  + S*T  + S T  + S T          |
|            0      0      0      0      0         |
|                                                  |
|o8 : ZZ[S, T ]                                    |
|            0                                     |
+--------------------------------------------------+

Since the number of variables in the degrees ring is equal to the rank of the
grading group, the Poincare polynomial may have more than one variable.

+------------------------------------------------------------------+
|i9 : S = ZZ/101[x,y,z, DegreeRank => 3];                          |
+------------------------------------------------------------------+
|i10 : L = koszulComplex vars S                                    |
|                                                                  |
|       1      3      3      1                                     |
|o10 = S  <-- S  <-- S  <-- S                                      |
|                                                                  |
|      0      1      2      3                                      |
|                                                                  |
|o10 : Complex                                                     |
+------------------------------------------------------------------+
|i11 : poincareN L                                                 |
|                                                                  |
|                                2        2        2        3      |
|o11 = 1 + S*T  + S*T  + S*T  + S T T  + S T T  + S T T  + S T T T |
|             2      1      0      1 2      0 2      0 1      0 1 2|
|                                                                  |
|o11 : ZZ[S, T ..T ]                                               |
|             0   2                                                |
+------------------------------------------------------------------+

If the terms in the complex are not free, then this method uses just the
degrees of the generators of each term.

+-----------------------------------------------------------------------------+
|i12 : D = C ** coker vars R                                                  |
|                                                                             |
|o12 = cokernel | a b c d e f | <-- cokernel {2} | a b c d e f 0 0 0 0 0 0 0 0|
|                                            {3} | 0 0 0 0 0 0 a b c d e f 0 0|
|      0                                     {4} | 0 0 0 0 0 0 0 0 0 0 0 0 a b|
|                                                                             |
|                                   1                                         |
|                                                                             |
|o12 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0 0 0 0 | <-- cokernel {4} | a b c d e f 0 0 0 0 0 0 |                       |
|0 0 0 0 |              {5} | 0 0 0 0 0 0 a b c d e f |                       |
|c d e f |                                                                    |
|              2                                                              |
+-----------------------------------------------------------------------------+
|i13 : poincareN D                                                            |
|                                                                             |
|             2      3      4    2 4    2 5                                   |
|o13 = 1 + S*T  + S*T  + S*T  + S T  + S T                                    |
|             0      0      0      0      0                                   |
|                                                                             |
|o13 : ZZ[S, T ]                                                              |
|             0                                                               |
+-----------------------------------------------------------------------------+
|i14 : betti D                                                                |
|                                                                             |
|             0 1 2                                                           |
|o14 = total: 1 3 2                                                           |
|          0: 1 . .                                                           |
|          1: . 1 .                                                           |
|          2: . 1 1                                                           |
|          3: . 1 1                                                           |
|                                                                             |
|o14 : BettiTally                                                             |
+-----------------------------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * poincare(Complex) -- assemble degrees of a
    chain complex into a polynomial
  * betti (Macaulay2Doc) -- display or modify a Betti diagram

Ways to use this method:
========================

  * poincareN(Complex) -- assemble degrees of a
    chain complex into a polynomial

randomComplexMap(Complex,Complex) -- a random map of chain complexes
********************************************************************

Synopsis
========

  * Function: randomComplexMap,
  * Usage:
        f = randomComplexMap(C,D)
  * Inputs:
      * C, a complex,
      * D, a complex,
  * Optional inputs (Macaulay2Doc),:
      * Boundary => a Boolean value (Macaulay2Doc), default
        value false, whether the constructed f is a null homotopy
      * Cycle => a Boolean value (Macaulay2Doc), default value
        false, whether the constructed f commutes with the differentials
      * Degree => an integer (Macaulay2Doc), default value 0, the
        degree of the constructed map of chain complexes
      * InternalDegree => a list (Macaulay2Doc), default value
        null, or an integer (Macaulay2Doc),
  * Outputs:
      * f, a map of complexes,

Description
===========

A random complex map $f : C \to D$ is obtained from a random element in the
complex $Hom(C,D)$.

+----------------------------------------------------------------------+
|i1 : S = ZZ/101[a..c]                                                 |
|                                                                      |
|o1 = S                                                                |
|                                                                      |
|o1 : PolynomialRing                                                   |
+----------------------------------------------------------------------+
|i2 : C = freeResolution coker matrix{{a*b, a*c, b*c}}                 |
|                                                                      |
|      1      3      2                                                 |
|o2 = S  <-- S  <-- S                                                  |
|                                                                      |
|     0      1      2                                                  |
|                                                                      |
|o2 : Complex                                                          |
+----------------------------------------------------------------------+
|i3 : D = freeResolution coker vars S                                  |
|                                                                      |
|      1      3      3      1                                          |
|o3 = S  <-- S  <-- S  <-- S                                           |
|                                                                      |
|     0      1      2      3                                           |
|                                                                      |
|o3 : Complex                                                          |
+----------------------------------------------------------------------+
|i4 : f = randomComplexMap(D,C)                                        |
|                                                                      |
|          1              1                                            |
|o4 = 0 : S  <---------- S  : 0                                        |
|               | 24 |                                                 |
|                                                                      |
|          3                                                      3    |
|     1 : S  <-------------------------------------------------- S  : 1|
|               {1} | -36a-30b-29c -29a-24b-38c -39a-18b-13c |         |
|               {1} | 19a+19b-10c  -16a+39b+21c -43a-15b-28c |         |
|               {1} | -29a-8b-22c  34a+19b-47c  -47a+38b+2c  |         |
|                                                                      |
|          3                                         2                 |
|     2 : S  <------------------------------------- S  : 2             |
|               {2} | 16a+22b+45c  7a+15b-23c   |                      |
|               {2} | -34a-48b-47c 39a+43b-17c  |                      |
|               {2} | 47a+19b-16c  -11a+48b+36c |                      |
|                                                                      |
|o4 : ComplexMap                                                       |
+----------------------------------------------------------------------+
|i5 : assert isWellDefined f                                           |
+----------------------------------------------------------------------+
|i6 : assert not isCommutative f                                       |
+----------------------------------------------------------------------+
|i7 : assert not isNullHomotopic f                                     |
+----------------------------------------------------------------------+

When the random element in the complex $Hom(C,D)$ lies in the kernel of the
differential, the associated map of complexes commutes with the differential.

+---------------------------------------------------------+
|i8 : g = randomComplexMap(D,C, Cycle => true)            |
|                                                         |
|          1               1                              |
|o8 = 0 : S  <----------- S  : 0                          |
|               | -50 |                                   |
|                                                         |
|          3                                         3    |
|     1 : S  <------------------------------------- S  : 1|
|               {1} | 40b-35c -46b+18c 28b+3c   |         |
|               {1} | 11a-11c 46a+22c  -28a-37c |         |
|               {1} | 35a+11b 33a-22b  -3a-13b  |         |
|                                                         |
|          3                                         2    |
|     2 : S  <------------------------------------- S  : 2|
|               {2} | 46b-49c      -28a-46b+17c |         |
|               {2} | -30b-35c     -3a+b        |         |
|               {2} | -38a-22b-11c -47a+22b     |         |
|                                                         |
|o8 : ComplexMap                                          |
+---------------------------------------------------------+
|i9 : assert isWellDefined g                              |
+---------------------------------------------------------+
|i10 : assert isCommutative g                             |
+---------------------------------------------------------+
|i11 : assert isComplexMorphism g                         |
+---------------------------------------------------------+
|i12 : assert not isNullHomotopic g                       |
+---------------------------------------------------------+

When the random element in the complex $Hom(C,D)$ lies in the image of the
differential, the associated map of complexes is a null homotopy.

+----------------------------------------------------------+
|i13 : h = randomComplexMap(D,C, Boundary => true)         |
|                                                          |
|           1         1                                    |
|o13 = 0 : S  <----- S  : 0                                |
|                0                                         |
|                                                          |
|           3                                         3    |
|      1 : S  <------------------------------------- S  : 1|
|                {1} | 23b+7c  -29b+47c 37b+13c  |         |
|                {1} | -23a-2c 29a-15c  -37a+10c |         |
|                {1} | -7a+2b  -47a+15b -13a-10b |         |
|                                                          |
|           3                                       2      |
|      2 : S  <----------------------------------- S  : 2  |
|                {2} | 29b-48c    -37a-29b-18c |           |
|                {2} | 24b+7c     -13a-36b     |           |
|                {2} | 30a+15b-2c -28a-15b     |           |
|                                                          |
|o13 : ComplexMap                                          |
+----------------------------------------------------------+
|i14 : assert isWellDefined h                              |
+----------------------------------------------------------+
|i15 : assert isCommutative h                              |
+----------------------------------------------------------+
|i16 : assert isComplexMorphism h                          |
+----------------------------------------------------------+
|i17 : assert isNullHomotopic h                            |
+----------------------------------------------------------+
|i18 : nullHomotopy h                                      |
|                                                          |
|           3         1                                    |
|o18 = 1 : S  <----- S  : 0                                |
|                0                                         |
|                                                          |
|           3                           3                  |
|      2 : S  <----------------------- S  : 1              |
|                {2} | -23 29  -37 |                       |
|                {2} | -7  -47 -13 |                       |
|                {2} | 2   15  -10 |                       |
|                                                          |
|           1                      2                       |
|      3 : S  <------------------ S  : 2                   |
|                {3} | 30 -18 |                            |
|                                                          |
|o18 : ComplexMap                                          |
+----------------------------------------------------------+

When the degree of the random element in the complex $Hom(C,D)$ is non-zero,
the associated map of complexes has the same degree.

+-----------------------------------------------------------------------------+
|i19 : p = randomComplexMap(D, C, Cycle => true, Degree => -1)                |
|                                                                             |
|                     1                                                       |
|o19 = -1 : 0 <----- S  : 0                                                   |
|                0                                                            |
|                                                                             |
|           1                                                                 |
|      0 : S  <---------------------------------------------------------------|
|                | 19a2-30ab+36b2+40ac+4bc-32c2 36a2+42ab-33b2+13ac-30bc+9c2 2|
|                                                                             |
|           3                                                                 |
|      1 : S  <---------------------------------------------------------------|
|                {1} | -10ab-31b2-20ac+31bc-39c2    -20a2+24ab-48b2-30ac-15bc+|
|                {1} | -26a2-11ab+33b2+34bc+4c2     33ab-33b2-49ac-19bc+17c2  |
|                {1} | 39a2+27ab+32b2-22ac-9bc-32c2 43a2-8ab-11b2+36ac-8bc    |
|                                                                             |
|o19 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                  3                                          |
|-------------------------------- S  : 1                                      |
|0a2+12ab-44b2-13ac-16bc+26c2 |                                               |
|                                                                             |
|          2                                                                  |
|-------- S  : 2                                                              |
|39c2 |                                                                       |
|     |                                                                       |
|     |                                                                       |
+-----------------------------------------------------------------------------+
|i20 : assert isWellDefined p                                                 |
+-----------------------------------------------------------------------------+
|i21 : assert isCommutative p                                                 |
+-----------------------------------------------------------------------------+
|i22 : assert not isComplexMorphism p                                         |
+-----------------------------------------------------------------------------+
|i23 : assert(degree p === -1)                                                |
+-----------------------------------------------------------------------------+

By default, the random element is constructed as a random linear combination of
the basis elements in the appropriate degree of $Hom(C,D)$.  Given an internal
degree, the random element is constructed as maps of modules with this degree.

+-----------------------------------------------------------------------------+
|i24 : q = randomComplexMap(D, C, Boundary => true, InternalDegree => 2)      |
|                                                                             |
|           1                                       1                         |
|o24 = 0 : S  <----------------------------------- S  : 0                     |
|                | -3a2+19ab+16b2-36ac+7bc-9c2 |                              |
|                                                                             |
|           3                                                                 |
|      1 : S  <---------------------------------------------------------------|
|                {1} | 32a2b-22ab2-40b3-25a2c-36abc-3b2c+2ac2-29bc2+49c3  47a2|
|                {1} | -35a3+41a2b-45ab2+6a2c-25abc+13b2c-31ac2-4bc2-30c3 -47a|
|                {1} | 25a3-6a2b+35ab2-13b3-2a2c-50abc+4b2c-49ac2+30bc2   -39a|
|                                                                             |
|           3                                                                 |
|      2 : S  <---------------------------------------------------------------|
|                {2} | -47a2b+27ab2+37b3-11a2c+9abc-33b2c-24ac2-11bc2+3c3     |
|                {2} | 7a2b+21ab2+30b3-25a2c-30abc+30b2c+2ac2-2bc2+49c3       |
|                {2} | -46a3+49a2b+42ab2-37b3-18a2c+23abc-41b2c-28ac2+48bc2-30|
|                                                                             |
|o24 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                                                             |
|-----------------------------------------------------------------------------|
|b-27ab2-37b3+36a2c+49abc-37b2c+18ac2-22bc2-30c3  -28a2b+18ab2-b3-10a2c+45abc+|
|3+27a2b+37ab2+a2c-19abc+37b2c+42ac2-47bc2+49c3   28a3-18a2b+ab2+43a2c+21abc+8|
|3-31a2b-29ab2-37b3+47a2c-13abc+47b2c+21ac2-49bc2 10a3+10a2b-28ab2+8b3+30a2c-1|
|                                                                             |
|                                                                 2           |
|--------------------------------------------------------------- S  : 2       |
|   28a3+29a2b-26ab2-37b3+46a2c-21abc+50b2c-22ac2+49bc2-16c3 |                |
|   10a3+46a2b+44ab2+14b3+30a2c+31abc+30b2c-13ac2-14bc2      |                |
|c3 3a3-41a2b+23ab2+37b3+8a2c-11abc-47b2c+14ac2+49bc2        |                |
|-----------------------------------------------------------------------------|
|                           3                                                 |
|------------------------- S  : 1                                             |
|26b2c-30ac2+9bc2+13c3 |                                                      |
|b2c-30ac2+bc2-30c3    |                                                      |
|5abc+6b2c-13ac2+21bc2 |                                                      |
+-----------------------------------------------------------------------------+
|i25 : assert all({0,1,2}, i -> degree q_i === {2})                           |
+-----------------------------------------------------------------------------+
|i26 : assert isHomogeneous q                                                 |
+-----------------------------------------------------------------------------+
|i27 : assert isWellDefined q                                                 |
+-----------------------------------------------------------------------------+
|i28 : assert isCommutative q                                                 |
+-----------------------------------------------------------------------------+
|i29 : assert isComplexMorphism q                                             |
+-----------------------------------------------------------------------------+
|i30 : source q === C                                                         |
|                                                                             |
|o30 = true                                                                   |
+-----------------------------------------------------------------------------+
|i31 : target q === D                                                         |
|                                                                             |
|o31 = true                                                                   |
+-----------------------------------------------------------------------------+
|i32 : assert isNullHomotopic q                                               |
+-----------------------------------------------------------------------------+

See also
========

  * homomorphism(ComplexMap) -- get the
    homomorphism from an element of Hom
  * homomorphism'(ComplexMap) -- get the
    element of Hom from a map of complexes
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes

Ways to use this method:
========================

  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes

regularity(Complex) -- compute the Castelnuovo-Mumford regularity
*****************************************************************

Synopsis
========

  * Function: regularity (Macaulay2Doc),
  * Usage:
        regularity C
  * Inputs:
      * C, a complex,
  * Optional inputs (Macaulay2Doc),:
      * Weights (Macaulay2Doc), => a list (Macaulay2Doc),
        default value null, for more information, see
        regularity(...,Weights=>...) (Macaulay2Doc),
  * Outputs:
      * an integer (Macaulay2Doc),

Description
===========

Given a free complex $C$ over a standard graded polynomial ring, the regularity
$r$ of $C$ is the smallest integer such that each basis element of $C_i$ has
degree at most $i + r$.

+-----------------------------------------------+
|i1 : R = ZZ/101[a..d];                         |
+-----------------------------------------------+
|i2 : I = ideal(b^2-a*c, b*c-a*d, c^2-b*d)      |
|                                               |
|             2                    2            |
|o2 = ideal (b  - a*c, b*c - a*d, c  - b*d)     |
|                                               |
|o2 : Ideal of R                                |
+-----------------------------------------------+
|i3 : C = freeResolution(R^1/I)                 |
|                                               |
|      1      3      2                          |
|o3 = R  <-- R  <-- R                           |
|                                               |
|     0      1      2                           |
|                                               |
|o3 : Complex                                   |
+-----------------------------------------------+
|i4 : betti C                                   |
|                                               |
|            0 1 2                              |
|o4 = total: 1 3 2                              |
|         0: 1 . .                              |
|         1: . 3 2                              |
|                                               |
|o4 : BettiTally                                |
+-----------------------------------------------+
|i5 : regularity C                              |
|                                               |
|o5 = 1                                         |
+-----------------------------------------------+
|i6 : regularity I                              |
|                                               |
|o6 = 2                                         |
+-----------------------------------------------+
|i7 : regularity (R^1/I)                        |
|                                               |
|o7 = 1                                         |
+-----------------------------------------------+
|i8 : assert(regularity C === regularity(R^1/I))|
+-----------------------------------------------+

The regularity is the label of the last row of the Betti table of $C$.

+----------------------+
|i9 : betti C          |
|                      |
|            0 1 2     |
|o9 = total: 1 3 2     |
|         0: 1 . .     |
|         1: . 3 2     |
|                      |
|o9 : BettiTally       |
+----------------------+
|i10 : betti(C[3])     |
|                      |
|             -3 -2 -1 |
|o10 = total:  1  3  2 |
|          3:  1  .  . |
|          4:  .  3  2 |
|                      |
|o10 : BettiTally      |
+----------------------+
|i11 : regularity(C[3])|
|                      |
|o11 = 4               |
+----------------------+

Here is a slightly more complicated example.

+-------------------------------------------------+
|i12 : J = ideal(a^3, b^3, c^3, d^3, (a+b+c+d)^3);|
|                                                 |
|o12 : Ideal of R                                 |
+-------------------------------------------------+
|i13 : FJ = freeResolution J                      |
|                                                 |
|       1      5      17      20      7           |
|o13 = R  <-- R  <-- R   <-- R   <-- R            |
|                                                 |
|      0      1      2       3       4            |
|                                                 |
|o13 : Complex                                    |
+-------------------------------------------------+
|i14 : betti FJ                                   |
|                                                 |
|             0 1  2  3 4                         |
|o14 = total: 1 5 17 20 7                         |
|          0: 1 .  .  . .                         |
|          1: . .  .  . .                         |
|          2: . 5  .  . .                         |
|          3: . .  .  . .                         |
|          4: . . 16 10 1                         |
|          5: . .  1 10 6                         |
|                                                 |
|o14 : BettiTally                                 |
+-------------------------------------------------+
|i15 : regularity FJ                              |
|                                                 |
|o15 = 5                                          |
+-------------------------------------------------+

Although Castelnuovo-Mumford regularity is defined in more general settings
(e.g. toric varieties with multi-degrees) this method does not currently handle
these extensions.  Similarly, Castelnuovo-Mumford regularity can be defined for
non-free complexes, but this method doesn't handle that case either.

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * regularity (Macaulay2Doc) -- compute the
    Castelnuovo-Mumford regularity
  * betti (Macaulay2Doc) -- display or modify a Betti diagram
  * freeResolution -- compute a free resolution of a
    module or ideal

Ways to use this method:
========================

  * regularity(Complex) -- compute the
    Castelnuovo-Mumford regularity

resolution(Complex) -- minimal free resolution of a complex
***********************************************************

Synopsis
========

  * Function: resolution (Macaulay2Doc),
  * Usage:
        resolution C
  * Inputs:
      * C, a complex,
  * Optional inputs (Macaulay2Doc),:
      * LengthLimit (Macaulay2Doc),
        => an integer (Macaulay2Doc), default value
        infinity, this is used to limit somehow the computation where
        resolutions might be too long or infinite
      * DegreeLimit (Macaulay2Doc),
        => ..., default value null, unused
      * FastNonminimal (Macaulay2Doc), => ..., default
        value false, unused
      * HardDegreeLimit (Macaulay2Doc),
        => ..., default value {}, unused
      * PairLimit (Macaulay2Doc),
        => ..., default value infinity, unused
      * SortStrategy (Macaulay2Doc),
        => ..., default value 0, unused
      * StopBeforeComputation (Macaulay2Doc),
        => ..., default value false, unused
      * Strategy (Macaulay2Doc),
        => ..., default value null, unused
      * SyzygyLimit (Macaulay2Doc),
        => ..., default value infinity, unused
  * Outputs:
      * a complex,

Description
===========

Given a complex $C$, this method produces a quasi-isomorphic complex $F$ all of
whose terms are free modules.  The algorithm used minimizes the ranks of the
free modules in $F$.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c];                                                      |
+-----------------------------------------------------------------------------+
|i2 : I = ideal(a^2, a*b, b*c)                                                |
|                                                                             |
|             2                                                               |
|o2 = ideal (a , a*b, b*c)                                                    |
|                                                                             |
|o2 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i3 : C = Hom(freeResolution I, R^1/I)                                        |
|                                                                             |
|o3 = cokernel {-3} | bc ab a2 0  0  0  | <-- cokernel {-2} | bc ab a2 0  0   |
|              {-3} | 0  0  0  bc ab a2 |              {-2} | 0  0  0  bc ab  |
|                                                      {-2} | 0  0  0  0  0   |
|     -2                                                                      |
|                                             -1                              |
|                                                                             |
|o3 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|0  0  0  0  | <-- cokernel | bc ab a2 |                                      |
|a2 0  0  0  |                                                                |
|0  bc ab a2 |     0                                                          |
+-----------------------------------------------------------------------------+
|i4 : assert all(min C .. max C, i -> not isFreeModule C_i)                   |
+-----------------------------------------------------------------------------+
|i5 : fC = resolutionMap C                                                    |
|                                                                             |
|                                                                             |
|o5 = -2 : cokernel {-3} | bc                                                 |
|                   {-3} | 0                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|     -1 : cokernel {-2} | bc                                                 |
|                   {-2} | 0                                                  |
|                   {-2} | 0                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|     0 : cokernel | bc ab a2                                                 |
|                                                                             |
|                                                                             |
|o5 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                      2                                      |
|ab a2 0  0  0  | <------------------ R  : -2                                 |
|0  0  bc ab a2 |    {-3} | -1 0  |                                           |
|                    {-3} | 0  -1 |                                           |
|                                                                             |
|                                                                   9         |
|ab a2 0  0  0  0  0  0  | <-------------------------------------- R  : -1    |
|0  0  bc ab a2 0  0  0  |    {-2} | 1 0  0  -c -a 0  0  0  0  |              |
|0  0  0  0  0  bc ab a2 |    {-2} | 0 -1 0  0  0  -b -a 0  0  |              |
|                             {-2} | 0 0  -1 0  0  0  -c -b -a |              |
|                                                                             |
|                                         14                                  |
|| <------------------------------------ R   : 0                              |
|     | 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 |                                        |
+-----------------------------------------------------------------------------+
|i6 : FC = resolution C                                                       |
|                                                                             |
|      2      9      14      9      2                                         |
|o6 = R  <-- R  <-- R   <-- R  <-- R                                          |
|                                                                             |
|     -2     -1     0       1      2                                          |
|                                                                             |
|o6 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i7 : prune HH FC                                                             |
|                                                                             |
|o7 = cokernel {-3} | b a  0 | <-- cokernel {-1} | b a  0 0 0 0 0 0 0 0  0 0 ||
|              {-3} | 0 -c a |              {-1} | 0 -c b a 0 0 0 0 0 0  0 0 ||
|                                           {-1} | 0 0  0 0 c a 0 0 0 0  0 0 ||
|     -2                                    {-1} | 0 0  0 0 0 0 b 0 0 a  0 0 ||
|                                           {-1} | 0 0  0 0 0 0 0 c a 0  0 0 ||
|                                           {-1} | 0 0  0 0 0 0 0 0 0 -c b a ||
|                                                                             |
|                                  -1                                         |
|                                                                             |
|o7 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|<-- cokernel | bc ab a2 |                                                    |
|                                                                             |
|    0                                                                        |
+-----------------------------------------------------------------------------+
|i8 : assert isQuasiIsomorphism fC                                            |
+-----------------------------------------------------------------------------+
|i9 : assert isFree FC                                                        |
+-----------------------------------------------------------------------------+
|i10 : assert isWellDefined fC                                                |
+-----------------------------------------------------------------------------+
|i11 : assert(0 == coker fC) -- showing that fC is surjective.                |
+-----------------------------------------------------------------------------+

The resolution of a short exact sequence is simply the zero complex.

+-----------------------------------------------------------------------------+
|i12 : J = ideal(a,b)                                                         |
|                                                                             |
|o12 = ideal (a, b)                                                           |
|                                                                             |
|o12 : Ideal of R                                                             |
+-----------------------------------------------------------------------------+
|i13 : K = ideal(b^2,c)                                                       |
|                                                                             |
|              2                                                              |
|o13 = ideal (b , c)                                                          |
|                                                                             |
|o13 : Ideal of R                                                             |
+-----------------------------------------------------------------------------+
|i14 : g1 = map(R^1/(J+K), R^1/J ++ R^1/K, {{1,-1}})                          |
|                                                                             |
|o14 = | 1 -1 |                                                               |
|                                                                             |
|o14 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i15 : g2 = map(R^1/J ++ R^1/K, R^1/(intersect(J,K)), {{1},{1}})              |
|                                                                             |
|o15 = | 1 |                                                                  |
|      | 1 |                                                                  |
|                                                                             |
|o15 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i16 : D = complex{g1, g2}                                                    |
|                                                                             |
|o16 = cokernel | a b b2 c | <-- cokernel | a b 0  0 | <-- cokernel | bc ac b2|
|                                         | 0 0 b2 c |                        |
|      0                                                   2                  |
|                                1                                            |
|                                                                             |
|o16 : Complex                                                                |
|-----------------------------------------------------------------------------|
||                                                                            |
+-----------------------------------------------------------------------------+
|i17 : assert isWellDefined D                                                 |
+-----------------------------------------------------------------------------+
|i18 : assert isShortExactSequence(g1,g2)                                     |
+-----------------------------------------------------------------------------+
|i19 : fD = resolutionMap D                                                   |
|                                                                             |
|o19 = 0                                                                      |
|                                                                             |
|o19 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i20 : assert isWellDefined fD                                                |
+-----------------------------------------------------------------------------+
|i21 : assert isQuasiIsomorphism fD                                           |
+-----------------------------------------------------------------------------+
|i22 : assert(0 == source fD) -- so fD is certainly not surjective!           |
+-----------------------------------------------------------------------------+

This method just accesses the cached value from the method
resolutionMap(Complex), which does the actual computation.

See also
========

  * resolutionMap(Complex) -- map from a free resolution
    to the given complex
  * freeResolution(Module) -- compute a free resolution
    of a module or ideal
  * isQuasiIsomorphism(ComplexMap),
    -- whether a map of complexes is a quasi-isomorphism

Ways to use this method:
========================

  * resolution(Complex) -- minimal free
    resolution of a complex

resolutionMap -- map from a free resolution to the given complex
****************************************************************

Synopsis
========

  * Usage:
        resolutionMap C
  * Inputs:
      * C, a complex,
  * Optional inputs (Macaulay2Doc),:
      * LengthLimit => an integer (Macaulay2Doc), default value
        infinity, this is used to limit somehow the computation where
        resolutions might be too long or infinite
      * DegreeLimit => ..., default value infinity, unused
      * FastNonminimal => ..., default value false, unused
      * HardDegreeLimit => ..., default value {}, unused
      * PairLimit => ..., default value infinity, unused
      * SortStrategy => ..., default value 0, unused
      * StopBeforeComputation => ..., default value false, unused
      * Strategy => ..., default value null, unused
      * SyzygyLimit => ..., default value infinity, unused
  * Outputs:
      * a map of complexes, a quasi-isomorphism whose source
        is a free resolution and whose target is $C$

Description
===========

Given a complex $C$, this method produces the natural quasi-isomorphism from a
complex $F$ all of whose terms are free modules to the complex $C$. The
algorithm used minimizes the ranks of the free modules in $F$.

+-----------------------------------------------------------------------------+
|i1 : R = ZZ/101[a,b,c];                                                      |
+-----------------------------------------------------------------------------+
|i2 : I = ideal(a^2, a*b, b*c)                                                |
|                                                                             |
|             2                                                               |
|o2 = ideal (a , a*b, b*c)                                                    |
|                                                                             |
|o2 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i3 : C = Hom(freeResolution I, R^1/I)                                        |
|                                                                             |
|o3 = cokernel {-3} | bc ab a2 0  0  0  | <-- cokernel {-2} | bc ab a2 0  0   |
|              {-3} | 0  0  0  bc ab a2 |              {-2} | 0  0  0  bc ab  |
|                                                      {-2} | 0  0  0  0  0   |
|     -2                                                                      |
|                                             -1                              |
|                                                                             |
|o3 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|0  0  0  0  | <-- cokernel | bc ab a2 |                                      |
|a2 0  0  0  |                                                                |
|0  bc ab a2 |     0                                                          |
+-----------------------------------------------------------------------------+
|i4 : assert all(min C .. max C, i -> not isFreeModule C_i)                   |
+-----------------------------------------------------------------------------+
|i5 : fC = resolutionMap C                                                    |
|                                                                             |
|                                                                             |
|o5 = -2 : cokernel {-3} | bc                                                 |
|                   {-3} | 0                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|     -1 : cokernel {-2} | bc                                                 |
|                   {-2} | 0                                                  |
|                   {-2} | 0                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|     0 : cokernel | bc ab a2                                                 |
|                                                                             |
|                                                                             |
|o5 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                      2                                      |
|ab a2 0  0  0  | <------------------ R  : -2                                 |
|0  0  bc ab a2 |    {-3} | -1 0  |                                           |
|                    {-3} | 0  -1 |                                           |
|                                                                             |
|                                                                   9         |
|ab a2 0  0  0  0  0  0  | <-------------------------------------- R  : -1    |
|0  0  bc ab a2 0  0  0  |    {-2} | 1 0  0  -c -a 0  0  0  0  |              |
|0  0  0  0  0  bc ab a2 |    {-2} | 0 -1 0  0  0  -b -a 0  0  |              |
|                             {-2} | 0 0  -1 0  0  0  -c -b -a |              |
|                                                                             |
|                                         14                                  |
|| <------------------------------------ R   : 0                              |
|     | 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 |                                        |
+-----------------------------------------------------------------------------+
|i6 : FC = resolution C                                                       |
|                                                                             |
|      2      9      14      9      2                                         |
|o6 = R  <-- R  <-- R   <-- R  <-- R                                          |
|                                                                             |
|     -2     -1     0       1      2                                          |
|                                                                             |
|o6 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i7 : prune HH FC                                                             |
|                                                                             |
|o7 = cokernel {-3} | b a  0 | <-- cokernel {-1} | b a  0 0 0 0 0 0 0 0  0 0 ||
|              {-3} | 0 -c a |              {-1} | 0 -c b a 0 0 0 0 0 0  0 0 ||
|                                           {-1} | 0 0  0 0 c a 0 0 0 0  0 0 ||
|     -2                                    {-1} | 0 0  0 0 0 0 b 0 0 a  0 0 ||
|                                           {-1} | 0 0  0 0 0 0 0 c a 0  0 0 ||
|                                           {-1} | 0 0  0 0 0 0 0 0 0 -c b a ||
|                                                                             |
|                                  -1                                         |
|                                                                             |
|o7 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|<-- cokernel | bc ab a2 |                                                    |
|                                                                             |
|    0                                                                        |
+-----------------------------------------------------------------------------+
|i8 : assert isQuasiIsomorphism fC                                            |
+-----------------------------------------------------------------------------+
|i9 : assert isFree FC                                                        |
+-----------------------------------------------------------------------------+
|i10 : assert isWellDefined fC                                                |
+-----------------------------------------------------------------------------+
|i11 : assert(0 == coker fC) -- showing that fC is surjective.                |
+-----------------------------------------------------------------------------+

The resolution of a short exact sequence is simply the zero complex.

+-----------------------------------------------------------------------------+
|i12 : J = ideal(a,b)                                                         |
|                                                                             |
|o12 = ideal (a, b)                                                           |
|                                                                             |
|o12 : Ideal of R                                                             |
+-----------------------------------------------------------------------------+
|i13 : K = ideal(b^2,c)                                                       |
|                                                                             |
|              2                                                              |
|o13 = ideal (b , c)                                                          |
|                                                                             |
|o13 : Ideal of R                                                             |
+-----------------------------------------------------------------------------+
|i14 : g1 = map(R^1/(J+K), R^1/J ++ R^1/K, {{1,-1}})                          |
|                                                                             |
|o14 = | 1 -1 |                                                               |
|                                                                             |
|o14 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i15 : g2 = map(R^1/J ++ R^1/K, R^1/(intersect(J,K)), {{1},{1}})              |
|                                                                             |
|o15 = | 1 |                                                                  |
|      | 1 |                                                                  |
|                                                                             |
|o15 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i16 : D = complex{g1, g2}                                                    |
|                                                                             |
|o16 = cokernel | a b b2 c | <-- cokernel | a b 0  0 | <-- cokernel | bc ac b2|
|                                         | 0 0 b2 c |                        |
|      0                                                   2                  |
|                                1                                            |
|                                                                             |
|o16 : Complex                                                                |
|-----------------------------------------------------------------------------|
||                                                                            |
+-----------------------------------------------------------------------------+
|i17 : assert isWellDefined D                                                 |
+-----------------------------------------------------------------------------+
|i18 : assert isShortExactSequence(g1,g2)                                     |
+-----------------------------------------------------------------------------+
|i19 : fD = resolutionMap D                                                   |
|                                                                             |
|o19 = 0                                                                      |
|                                                                             |
|o19 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i20 : assert isWellDefined fD                                                |
+-----------------------------------------------------------------------------+
|i21 : assert isQuasiIsomorphism fD                                           |
+-----------------------------------------------------------------------------+
|i22 : assert(0 == source fD) -- so fD is certainly not surjective!           |
+-----------------------------------------------------------------------------+

To avoid recomputation, this method caches its value.

See also
========

  * resolution(Complex) -- minimal free
    resolution of a complex
  * freeResolution(Module) -- compute a free resolution
    of a module or ideal
  * isQuasiIsomorphism(ComplexMap),
    -- whether a map of complexes is a quasi-isomorphism

Ways to use resolutionMap :
===========================

  * "resolutionMap(Complex)"

For the programmer
==================

The object resolutionMap, is a method function with options (Macaulay2Doc).

ring(Complex) -- access the ring of a complex or a complex map
**************************************************************

Synopsis
========

  * Function: ring (Macaulay2Doc),
  * Usage:
        ring C
  * Inputs:
      * C, a complex, or a ComplexMap,
  * Outputs:
      * a ring (Macaulay2Doc),

Description
===========

Every complex or complex map has a base ring.  This function access that
information.

+------------------------------------+
|i1 : S = ZZ/101[a,b,c,d];           |
+------------------------------------+
|i2 : C = freeResolution coker vars S|
|                                    |
|      1      4      6      4      1 |
|o2 = S  <-- S  <-- S  <-- S  <-- S  |
|                                    |
|     0      1      2      3      4  |
|                                    |
|o2 : Complex                        |
+------------------------------------+
|i3 : ring C                         |
|                                    |
|o3 = S                              |
|                                    |
|o3 : PolynomialRing                 |
+------------------------------------+
|i4 : assert(ring C === S)           |
+------------------------------------+
|i5 : ring id_C                      |
|                                    |
|o5 = S                              |
|                                    |
|o5 : PolynomialRing                 |
+------------------------------------+
|i6 : assert(ring id_C === S)        |
+------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * ring (Macaulay2Doc) -- get the associated ring of an object

Ways to use this method:
========================

  * ring(Complex) -- access the ring of a complex or
    a complex map
  * "ring(ComplexMap)"

RingMap ** Complex -- tensor a complex along a ring map
*******************************************************

Synopsis
========

  * Operator: ** (Macaulay2Doc),
  * Usage:
        phi ** C
        tensor(phi, C)
        S ** C
        C ** S
  * Inputs:
      * phi, a ring map (Macaulay2Doc), whose source is a ring
        $R$ and whose target is a ring $S$
      * C, a complex, over the ring $R$
  * Outputs:
      * a complex, over the ring $S$

Description
===========

These methods implement the base change of rings.  As input, one can either
give a ring map $\phi$, or the ring $S$ (when there is a canonical map from $R$
to $S$).

We illustrate the tensor product of a complex along a ring map.

+---------------------------------------------------------------------------+
|i1 : R = QQ[x,y,z];                                                        |
+---------------------------------------------------------------------------+
|i2 : S = QQ[s,t];                                                          |
+---------------------------------------------------------------------------+
|i3 : phi = map(S, R, {s, s+t, t})                                          |
|                                                                           |
|o3 = map (S, R, {s, s + t, t})                                             |
|                                                                           |
|o3 : RingMap S <--- R                                                      |
+---------------------------------------------------------------------------+
|i4 : I = ideal(x^3, x^2*y, x*y^4, y*z^5)                                   |
|                                                                           |
|             3   2      4     5                                            |
|o4 = ideal (x , x y, x*y , y*z )                                           |
|                                                                           |
|o4 : Ideal of R                                                            |
+---------------------------------------------------------------------------+
|i5 : C = freeResolution I                                                  |
|                                                                           |
|      1      4      4      1                                               |
|o5 = R  <-- R  <-- R  <-- R                                                |
|                                                                           |
|     0      1      2      3                                                |
|                                                                           |
|o5 : Complex                                                               |
+---------------------------------------------------------------------------+
|i6 : D = phi ** C                                                          |
|                                                                           |
|      1      4      4      1                                               |
|o6 = S  <-- S  <-- S  <-- S                                                |
|                                                                           |
|     0      1      2      3                                                |
|                                                                           |
|o6 : Complex                                                               |
+---------------------------------------------------------------------------+
|i7 : assert isWellDefined D                                                |
+---------------------------------------------------------------------------+
|i8 : dd^D                                                                  |
|                                                                           |
|          1                                                    4           |
|o8 = 0 : S  <------------------------------------------------ S  : 1       |
|               | s3 s3+s2t s5+4s4t+6s3t2+4s2t3+st4 st5+t6 |                |
|                                                                           |
|          4                                                           4    |
|     1 : S  <------------------------------------------------------- S  : 2|
|               {3} | -s-t 0                0   0                 |         |
|               {3} | s    -s3-3s2t-3st2-t3 -t5 0                 |         |
|               {5} | 0    s                0   -t5               |         |
|               {6} | 0    0                s2  s4+3s3t+3s2t2+st3 |         |
|                                                                           |
|          4                                 1                              |
|     2 : S  <----------------------------- S  : 3                          |
|               {4}  | 0                |                                   |
|               {6}  | t5               |                                   |
|               {8}  | -s3-3s2t-3st2-t3 |                                   |
|               {10} | s                |                                   |
|                                                                           |
|o8 : ComplexMap                                                            |
+---------------------------------------------------------------------------+
|i9 : prune HH D                                                            |
|                                                                           |
|o9 = cokernel | s2t s3 st4 t6 | <-- cokernel {7} | s t3 |                  |
|                                                                           |
|     0                              1                                      |
|                                                                           |
|o9 : Complex                                                               |
+---------------------------------------------------------------------------+

If a ring is used rather than a ring map, then the implicit map from the
underlying ring of the complex to the given ring is used.

+-------------------------------------+
|i10 : A = R/(x^2+y^2+z^2);           |
+-------------------------------------+
|i11 : C ** A                         |
|                                     |
|       1      4      4      1        |
|o11 = A  <-- A  <-- A  <-- A         |
|                                     |
|      0      1      2      3         |
|                                     |
|o11 : Complex                        |
+-------------------------------------+
|i12 : assert(map(A,R) ** C == C ** A)|
+-------------------------------------+

The commutativity of tensor product is witnessed as follows.

+------------------------------+
|i13 : assert(D == C ** phi)   |
+------------------------------+
|i14 : assert(C ** A == A ** C)|
+------------------------------+

When the modules in the complex are not free modules, this is different than
the image of a complex under a ring map.

+--------------------------------------------------------------------------+
|i15 : use R                                                               |
|                                                                          |
|o15 = R                                                                   |
|                                                                          |
|o15 : PolynomialRing                                                      |
+--------------------------------------------------------------------------+
|i16 : I = ideal(x*y, x*z, y*z);                                           |
|                                                                          |
|o16 : Ideal of R                                                          |
+--------------------------------------------------------------------------+
|i17 : J = I + ideal(x^2, y^2);                                            |
|                                                                          |
|o17 : Ideal of R                                                          |
+--------------------------------------------------------------------------+
|i18 : g = inducedMap(module J, module I)                                  |
|                                                                          |
|o18 = {2} | 1 0 0 |                                                       |
|      {2} | 0 1 0 |                                                       |
|      {2} | 0 0 1 |                                                       |
|      {2} | 0 0 0 |                                                       |
|      {2} | 0 0 0 |                                                       |
|                                                                          |
|o18 : Matrix                                                              |
+--------------------------------------------------------------------------+
|i19 : assert isWellDefined g                                              |
+--------------------------------------------------------------------------+
|i20 : C = complex {g}                                                     |
|                                                                          |
|o20 = image | xy xz yz x2 y2 | <-- image | xy xz yz |                     |
|                                                                          |
|      0                            1                                      |
|                                                                          |
|o20 : Complex                                                             |
+--------------------------------------------------------------------------+
|i21 : D1 = phi C                                                          |
|                                                                          |
|o21 = image | s2+st st st+t2 s2 s2+2st+t2 | <-- image | s2+st st st+t2 |  |
|                                                                          |
|      0                                         1                         |
|                                                                          |
|o21 : Complex                                                             |
+--------------------------------------------------------------------------+
|i22 : assert isWellDefined D1                                             |
+--------------------------------------------------------------------------+
|i23 : D2 = phi ** C                                                       |
|                                                                          |
|o23 = cokernel {2} | -t  -t 0  s    0   -s-t | <-- cokernel {2} | -t  -t ||
|               {2} | s+t 0  s  0    0   0    |              {2} | s+t 0  ||
|               {2} | 0   s  0  0    s+t 0    |              {2} | 0   s  ||
|               {2} | 0   0  -t -s-t 0   0    |                            |
|               {2} | 0   0  0  0    -t  s    |     1                      |
|                                                                          |
|      0                                                                   |
|                                                                          |
|o23 : Complex                                                             |
+--------------------------------------------------------------------------+
|i24 : assert isWellDefined D2                                             |
+--------------------------------------------------------------------------+
|i25 : prune D1                                                            |
|                                                                          |
|o25 = cokernel {2} | s+t t    | <-- cokernel {2} | -t  -t |               |
|               {2} | 0   -s-t |              {2} | s+t 0  |               |
|               {2} | -t  s-t  |              {2} | 0   s  |               |
|                                                                          |
|      0                             1                                     |
|                                                                          |
|o25 : Complex                                                             |
+--------------------------------------------------------------------------+
|i26 : prune D2                                                            |
|                                                                          |
|o26 = cokernel {2} | -t  -t -t -s+t -t -s-t | <-- cokernel {2} | -t  -t | |
|               {2} | s+t 0  t  -t   0  0    |              {2} | s+t 0  | |
|               {2} | 0   s  0  0    -t 0    |              {2} | 0   s  | |
|               {2} | 0   0  t  s    0  0    |                             |
|               {2} | 0   0  0  0    t  s    |     1                       |
|                                                                          |
|      0                                                                   |
|                                                                          |
|o26 : Complex                                                             |
+--------------------------------------------------------------------------+

When the ring map doesn't preserve homogeneity, the DegreeMap (Macaulay2Doc),
option is needed to determine the degrees of the image
free modules in the complex.

+-----------------------------------------------------------------------------+
|i27 : R = ZZ/101[a..d];                                                      |
+-----------------------------------------------------------------------------+
|i28 : S = ZZ/101[s,t];                                                       |
+-----------------------------------------------------------------------------+
|i29 : f = map(S, R, {s^4, s^3*t, s*t^3, t^4}, DegreeMap => i -> 4*i)         |
|                                                                             |
|                   4   3      3   4                                          |
|o29 = map (S, R, {s , s t, s*t , t })                                        |
|                                                                             |
|o29 : RingMap S <--- R                                                       |
+-----------------------------------------------------------------------------+
|i30 : C = freeResolution coker vars R                                        |
|                                                                             |
|       1      4      6      4      1                                         |
|o30 = R  <-- R  <-- R  <-- R  <-- R                                          |
|                                                                             |
|      0      1      2      3      4                                          |
|                                                                             |
|o30 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i31 : D = f ** C                                                             |
|                                                                             |
|       1      4      6      4      1                                         |
|o31 = S  <-- S  <-- S  <-- S  <-- S                                          |
|                                                                             |
|      0      1      2      3      4                                          |
|                                                                             |
|o31 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i32 : D == f C                                                               |
|                                                                             |
|o32 = true                                                                   |
+-----------------------------------------------------------------------------+
|i33 : assert isWellDefined D                                                 |
+-----------------------------------------------------------------------------+
|i34 : assert isHomogeneous D                                                 |
+-----------------------------------------------------------------------------+
|i35 : prune HH D                                                             |
|                                                                             |
|o35 = cokernel | t4 st3 s3t s4 | <-- cokernel {5} | s3 0  t3 0   0  st2 | <--|
|                                              {5} | 0  t3 s3 s2t 0  0   |    |
|      0                                       {6} | 0  0  0  t2  st s2  |    |
|                                                                             |
|                                     1                                       |
|                                                                             |
|o35 : Complex                                                                |
|-----------------------------------------------------------------------------|
|cokernel {10} | s2 0 0 t2 |                                                  |
|         {11} | t  s 0 0  |                                                  |
|         {11} | 0  0 t s  |                                                  |
|                                                                             |
|2                                                                            |
+-----------------------------------------------------------------------------+
|i36 : C1 = Hom(C, image vars R)                                              |
|                                                                             |
|o36 = image {-4} | d c b a | <-- image {-3} | d c b a 0 0 0 0 0 0 0 0 0 0 0 0|
|                                       {-3} | 0 0 0 0 d c b a 0 0 0 0 0 0 0 0|
|      -4                               {-3} | 0 0 0 0 0 0 0 0 d c b a 0 0 0 0|
|                                       {-3} | 0 0 0 0 0 0 0 0 0 0 0 0 d c b a|
|                                                                             |
|                                 -3                                          |
|                                                                             |
|                                                                             |
|                                                                             |
|o36 : Complex                                                                |
|-----------------------------------------------------------------------------|
|| <-- image {-2} | d c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | <--     |
||           {-2} | 0 0 0 0 d c b a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
||           {-2} | 0 0 0 0 0 0 0 0 d c b a 0 0 0 0 0 0 0 0 0 0 0 0 |         |
||           {-2} | 0 0 0 0 0 0 0 0 0 0 0 0 d c b a 0 0 0 0 0 0 0 0 |         |
|            {-2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 d c b a 0 0 0 0 |         |
|            {-2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 d c b a |         |
|                                                                             |
|      -2                                                                     |
|-----------------------------------------------------------------------------|
|image {-1} | d c b a 0 0 0 0 0 0 0 0 0 0 0 0 | <-- image | d c b a |         |
|      {-1} | 0 0 0 0 d c b a 0 0 0 0 0 0 0 0 |                               |
|      {-1} | 0 0 0 0 0 0 0 0 d c b a 0 0 0 0 |     0                         |
|      {-1} | 0 0 0 0 0 0 0 0 0 0 0 0 d c b a |                               |
|                                                                             |
|-1                                                                           |
+-----------------------------------------------------------------------------+
|i37 : D1 = f ** C1                                                           |
|                                                                             |
|o37 = cokernel {-12} | st3 s3t 0    s4  0    0    | <-- cokernel {-8} | st3  |
|               {-12} | -t4 0   s3t  0   s4   0    |              {-8} | -t4  |
|               {-12} | 0   -t4 -st3 0   0    s4   |              {-8} | 0    |
|               {-12} | 0   0   0    -t4 -st3 -s3t |              {-8} | 0    |
|                                                                 {-8} | 0    |
|      -4                                                         {-8} | 0    |
|                                                                 {-8} | 0    |
|                                                                 {-8} | 0    |
|                                                                 {-8} | 0    |
|                                                                 {-8} | 0    |
|                                                                 {-8} | 0    |
|                                                                 {-8} | 0    |
|                                                                 {-8} | 0    |
|                                                                 {-8} | 0    |
|                                                                 {-8} | 0    |
|                                                                 {-8} | 0    |
|                                                                             |
|                                                        -3                   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o37 : Complex                                                                |
|-----------------------------------------------------------------------------|
|s3t 0    s4  0    0    0   0   0    0   0    0    0   0   0    0   0    0    |
|0   s3t  0   s4   0    0   0   0    0   0    0    0   0   0    0   0    0    |
|-t4 -st3 0   0    s4   0   0   0    0   0    0    0   0   0    0   0    0    |
|0   0    -t4 -st3 -s3t 0   0   0    0   0    0    0   0   0    0   0    0    |
|0   0    0   0    0    st3 s3t 0    s4  0    0    0   0   0    0   0    0    |
|0   0    0   0    0    -t4 0   s3t  0   s4   0    0   0   0    0   0    0    |
|0   0    0   0    0    0   -t4 -st3 0   0    s4   0   0   0    0   0    0    |
|0   0    0   0    0    0   0   0    -t4 -st3 -s3t 0   0   0    0   0    0    |
|0   0    0   0    0    0   0   0    0   0    0    st3 s3t 0    s4  0    0    |
|0   0    0   0    0    0   0   0    0   0    0    -t4 0   s3t  0   s4   0    |
|0   0    0   0    0    0   0   0    0   0    0    0   -t4 -st3 0   0    s4   |
|0   0    0   0    0    0   0   0    0   0    0    0   0   0    -t4 -st3 -s3t |
|0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0    0    |
|0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0    0    |
|0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0    0    |
|0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0    0    |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|0   0   0    0   0    0    | <-- cokernel {-4} | st3 s3t 0    s4  0    0     |
|0   0   0    0   0    0    |              {-4} | -t4 0   s3t  0   s4   0     |
|0   0   0    0   0    0    |              {-4} | 0   -t4 -st3 0   0    s4    |
|0   0   0    0   0    0    |              {-4} | 0   0   0    -t4 -st3 -s3t  |
|0   0   0    0   0    0    |              {-4} | 0   0   0    0   0    0     |
|0   0   0    0   0    0    |              {-4} | 0   0   0    0   0    0     |
|0   0   0    0   0    0    |              {-4} | 0   0   0    0   0    0     |
|0   0   0    0   0    0    |              {-4} | 0   0   0    0   0    0     |
|0   0   0    0   0    0    |              {-4} | 0   0   0    0   0    0     |
|0   0   0    0   0    0    |              {-4} | 0   0   0    0   0    0     |
|0   0   0    0   0    0    |              {-4} | 0   0   0    0   0    0     |
|0   0   0    0   0    0    |              {-4} | 0   0   0    0   0    0     |
|st3 s3t 0    s4  0    0    |              {-4} | 0   0   0    0   0    0     |
|-t4 0   s3t  0   s4   0    |              {-4} | 0   0   0    0   0    0     |
|0   -t4 -st3 0   0    s4   |              {-4} | 0   0   0    0   0    0     |
|0   0   0    -t4 -st3 -s3t |              {-4} | 0   0   0    0   0    0     |
|                                          {-4} | 0   0   0    0   0    0     |
|                                          {-4} | 0   0   0    0   0    0     |
|                                          {-4} | 0   0   0    0   0    0     |
|                                          {-4} | 0   0   0    0   0    0     |
|                                          {-4} | 0   0   0    0   0    0     |
|                                          {-4} | 0   0   0    0   0    0     |
|                                          {-4} | 0   0   0    0   0    0     |
|                                          {-4} | 0   0   0    0   0    0     |
|                                                                             |
|                                 -2                                          |
|-----------------------------------------------------------------------------|
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|st3 s3t 0    s4  0    0    0   0   0    0   0    0    0   0   0    0   0     |
|-t4 0   s3t  0   s4   0    0   0   0    0   0    0    0   0   0    0   0     |
|0   -t4 -st3 0   0    s4   0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    -t4 -st3 -s3t 0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    st3 s3t 0    s4  0    0    0   0   0    0   0     |
|0   0   0    0   0    0    -t4 0   s3t  0   s4   0    0   0   0    0   0     |
|0   0   0    0   0    0    0   -t4 -st3 0   0    s4   0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    -t4 -st3 -s3t 0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    st3 s3t 0    s4  0     |
|0   0   0    0   0    0    0   0   0    0   0    0    -t4 0   s3t  0   s4    |
|0   0   0    0   0    0    0   0   0    0   0    0    0   -t4 -st3 0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    -t4 -st3  |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|-----------------------------------------------------------------------------|
|0    0   0   0    0   0    0    0   0   0    0   0    0    | <-- cokernel |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|s4   0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|-s3t 0   0   0    0   0    0    0   0   0    0   0    0    |              |  |
|0    st3 s3t 0    s4  0    0    0   0   0    0   0    0    |                 |
|0    -t4 0   s3t  0   s4   0    0   0   0    0   0    0    |     -1          |
|0    0   -t4 -st3 0   0    s4   0   0   0    0   0    0    |                 |
|0    0   0   0    -t4 -st3 -s3t 0   0   0    0   0    0    |                 |
|0    0   0   0    0   0    0    st3 s3t 0    s4  0    0    |                 |
|0    0   0   0    0   0    0    -t4 0   s3t  0   s4   0    |                 |
|0    0   0   0    0   0    0    0   -t4 -st3 0   0    s4   |                 |
|0    0   0   0    0   0    0    0   0   0    -t4 -st3 -s3t |                 |
|-----------------------------------------------------------------------------|
|st3 s3t 0    s4  0    0    0   0   0    0   0    0    0   0   0    0   0     |
|-t4 0   s3t  0   s4   0    0   0   0    0   0    0    0   0   0    0   0     |
|0   -t4 -st3 0   0    s4   0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    -t4 -st3 -s3t 0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    st3 s3t 0    s4  0    0    0   0   0    0   0     |
|0   0   0    0   0    0    -t4 0   s3t  0   s4   0    0   0   0    0   0     |
|0   0   0    0   0    0    0   -t4 -st3 0   0    s4   0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    -t4 -st3 -s3t 0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    st3 s3t 0    s4  0     |
|0   0   0    0   0    0    0   0   0    0   0    0    -t4 0   s3t  0   s4    |
|0   0   0    0   0    0    0   0   0    0   0    0    0   -t4 -st3 0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    -t4 -st3  |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|0   0   0    0   0    0    0   0   0    0   0    0    0   0   0    0   0     |
|-----------------------------------------------------------------------------|
|0    0   0   0    0   0    0    | <-- cokernel {4} | st3 s3t 0    s4  0      |
|0    0   0   0    0   0    0    |              {4} | -t4 0   s3t  0   s4     |
|0    0   0   0    0   0    0    |              {4} | 0   -t4 -st3 0   0      |
|0    0   0   0    0   0    0    |              {4} | 0   0   0    -t4 -st3   |
|0    0   0   0    0   0    0    |                                            |
|0    0   0   0    0   0    0    |     0                                      |
|0    0   0   0    0   0    0    |                                            |
|0    0   0   0    0   0    0    |                                            |
|0    0   0   0    0   0    0    |                                            |
|0    0   0   0    0   0    0    |                                            |
|s4   0   0   0    0   0    0    |                                            |
|-s3t 0   0   0    0   0    0    |                                            |
|0    st3 s3t 0    s4  0    0    |                                            |
|0    -t4 0   s3t  0   s4   0    |                                            |
|0    0   -t4 -st3 0   0    s4   |                                            |
|0    0   0   0    -t4 -st3 -s3t |                                            |
|-----------------------------------------------------------------------------|
|0    |                                                                       |
|0    |                                                                       |
|s4   |                                                                       |
|-s3t |                                                                       |
+-----------------------------------------------------------------------------+
|i38 : isWellDefined D1                                                       |
|                                                                             |
|o38 = true                                                                   |
+-----------------------------------------------------------------------------+
|i39 : assert isHomogeneous D1                                                |
+-----------------------------------------------------------------------------+

See also
========

  * RingMap ** ComplexMap -- tensor a map of
    complexes along a ring map
  * RingMap Complex -- apply a ring map

Ways to use this method:
========================

  * "Complex ** Ring"
  * "Complex ** RingMap"
  * "Ring ** Complex"
  * RingMap ** Complex -- tensor a complex along
    a ring map

RingMap ** ComplexMap -- tensor a map of complexes along a ring map
*******************************************************************

Synopsis
========

  * Operator: ** (Macaulay2Doc),
  * Usage:
        phi ** f
        tensor(phi, f)
        S ** f
        f ** S
  * Inputs:
      * phi, a ring map (Macaulay2Doc), whose source is a ring
        $R$, and whose target is a ring $S$
      * f, a map of complexes, over the ring $R$
  * Outputs:
      * a map of complexes, over the ring $S$

Description
===========

These methods implement the base change of rings.  As input, one can either
give a ring map $\phi$, or the ring $S$ (when there is a canonical map from $R$
to $S$).

We illustrate the tensor product of a map of complexes along a ring map.

+-----------------------------------------------------------------------------+
|i1 : R = QQ[a,b,c,d];                                                        |
+-----------------------------------------------------------------------------+
|i2 : S = QQ[s,t];                                                            |
+-----------------------------------------------------------------------------+
|i3 : phi = map(S, R, {s, s+t, t, s-t})                                       |
|                                                                             |
|o3 = map (S, R, {s, s + t, t, s - t})                                        |
|                                                                             |
|o3 : RingMap S <--- R                                                        |
+-----------------------------------------------------------------------------+
|i4 : I = ideal(a*b, b*c, c*d)                                                |
|                                                                             |
|o4 = ideal (a*b, b*c, c*d)                                                   |
|                                                                             |
|o4 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i5 : J = I + ideal(a^2, b^2, c^2, d^2)                                       |
|                                                                             |
|                            2   2   2   2                                    |
|o5 = ideal (a*b, b*c, c*d, a , b , c , d )                                   |
|                                                                             |
|o5 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i6 : CI = freeResolution I                                                   |
|                                                                             |
|      1      3      2                                                        |
|o6 = R  <-- R  <-- R                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o6 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i7 : CJ = freeResolution J                                                   |
|                                                                             |
|      1      7      13      10      3                                        |
|o7 = R  <-- R  <-- R   <-- R   <-- R                                         |
|                                                                             |
|     0      1      2       3       4                                         |
|                                                                             |
|o7 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i8 : f = extend(CJ, CI, map(CJ_0, CI_0, 1))                                  |
|                                                                             |
|          1             1                                                    |
|o8 = 0 : R  <--------- R  : 0                                                |
|               | 1 |                                                         |
|                                                                             |
|          7                     3                                            |
|     1 : R  <----------------- R  : 1                                        |
|               {2} | 0 0 0 |                                                 |
|               {2} | 1 0 0 |                                                 |
|               {2} | 0 0 0 |                                                 |
|               {2} | 0 1 0 |                                                 |
|               {2} | 0 0 0 |                                                 |
|               {2} | 0 0 1 |                                                 |
|               {2} | 0 0 0 |                                                 |
|                                                                             |
|          13                   2                                             |
|     2 : R   <--------------- R  : 2                                         |
|                {3} | 0 0 |                                                  |
|                {3} | 0 0 |                                                  |
|                {3} | 1 0 |                                                  |
|                {3} | 0 0 |                                                  |
|                {3} | 0 0 |                                                  |
|                {3} | 0 1 |                                                  |
|                {3} | 0 0 |                                                  |
|                {3} | 0 0 |                                                  |
|                {4} | 0 0 |                                                  |
|                {4} | 0 0 |                                                  |
|                {4} | 0 0 |                                                  |
|                {4} | 0 0 |                                                  |
|                {4} | 0 0 |                                                  |
|                                                                             |
|o8 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i9 : assert isWellDefined f                                                  |
+-----------------------------------------------------------------------------+
|i10 : g = phi ** f                                                           |
|                                                                             |
|           1             1                                                   |
|o10 = 0 : S  <--------- S  : 0                                               |
|                | 1 |                                                        |
|                                                                             |
|           7                     3                                           |
|      1 : S  <----------------- S  : 1                                       |
|                {2} | 0 0 0 |                                                |
|                {2} | 1 0 0 |                                                |
|                {2} | 0 0 0 |                                                |
|                {2} | 0 1 0 |                                                |
|                {2} | 0 0 0 |                                                |
|                {2} | 0 0 1 |                                                |
|                {2} | 0 0 0 |                                                |
|                                                                             |
|           13                   2                                            |
|      2 : S   <--------------- S  : 2                                        |
|                 {3} | 0 0 |                                                 |
|                 {3} | 0 0 |                                                 |
|                 {3} | 1 0 |                                                 |
|                 {3} | 0 0 |                                                 |
|                 {3} | 0 0 |                                                 |
|                 {3} | 0 1 |                                                 |
|                 {3} | 0 0 |                                                 |
|                 {3} | 0 0 |                                                 |
|                 {4} | 0 0 |                                                 |
|                 {4} | 0 0 |                                                 |
|                 {4} | 0 0 |                                                 |
|                 {4} | 0 0 |                                                 |
|                 {4} | 0 0 |                                                 |
|                                                                             |
|o10 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i11 : assert isWellDefined g                                                 |
+-----------------------------------------------------------------------------+
|i12 : dd^(source g)                                                          |
|                                                                             |
|           1                             3                                   |
|o12 = 0 : S  <------------------------- S  : 1                               |
|                | s2+st st+t2 st-t2 |                                        |
|                                                                             |
|           3                       2                                         |
|      1 : S  <------------------- S  : 2                                     |
|                {2} | -t 0    |                                              |
|                {2} | s  -s+t |                                              |
|                {2} | 0  s+t  |                                              |
|                                                                             |
|o12 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i13 : dd^(target g)                                                          |
|                                                                             |
|           1                                                       7         |
|o13 = 0 : S  <--------------------------------------------------- S  : 1     |
|                | s2 s2+st s2+2st+t2 st+t2 t2 st-t2 s2-2st+t2 |              |
|                                                                             |
|           7                                                                 |
|      1 : S  <---------------------------------------------------------------|
|                {2} | -s-t 0    0  0   0   0    0    0    -t2 -st+t2 -s2+2st-|
|                {2} | s    -s-t -t 0   0   0    0    0    0   0      0       |
|                {2} | 0    s    0  -t  0   0    0    0    0   0      0       |
|                {2} | 0    0    s  s+t -t  -s+t 0    0    0   0      0       |
|                {2} | 0    0    0  0   s+t 0    -s+t 0    s2  0      0       |
|                {2} | 0    0    0  0   0   s+t  t    -s+t 0   s2     0       |
|                {2} | 0    0    0  0   0   0    0    t    0   0      s2      |
|                                                                             |
|           13                                                                |
|      2 : S   <--------------------------------------------------------------|
|                 {3} | 0    0   -t2 -st+t2 0    s2-2st+t2 0         0    0   |
|                 {3} | t    0   0   0      0    0         s2-2st+t2 0    0   |
|                 {3} | -s-t 0   -st -s2+st 0    0         0         0    -s2+|
|                 {3} | s    0   0   0      0    0         0         0    0   |
|                 {3} | 0    s-t -s2 0      0    0         0         0    0   |
|                 {3} | 0    -t  0   -s2    0    0         0         0    -s2+|
|                 {3} | 0    s+t 0   0      -s2  0         0         0    0   |
|                 {3} | 0    0   0   0      0    0         0         -s2  -s2-|
|                 {4} | 0    0   s+t 0      -s+t 0         0         0    0   |
|                 {4} | 0    0   0   s+t    t    0         0         -s+t 0   |
|                 {4} | 0    0   0   0      0    -s-t      0         t    0   |
|                 {4} | 0    0   0   0      0    s         -s-t      0    t   |
|                 {4} | 0    0   0   0      0    0         s         0    0   |
|                                                                             |
|           10                                  3                             |
|      3 : S   <------------------------------ S  : 4                         |
|                 {4} | 0   0    s2-2st+t2 |                                  |
|                 {4} | s2  0    0         |                                  |
|                 {5} | s-t 0    0         |                                  |
|                 {5} | -t  -s+t 0         |                                  |
|                 {5} | s+t 0    0         |                                  |
|                 {5} | 0   -t   0         |                                  |
|                 {5} | 0   0    -t        |                                  |
|                 {5} | 0   -s-t 0         |                                  |
|                 {5} | 0   s    -s-t      |                                  |
|                 {5} | 0   0    s         |                                  |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                              13                                             |
|---------------------------- S   : 2                                         |
|t2 0          0          |                                                   |
|   -s2+2st-t2 0          |                                                   |
|   0          -s2+2st-t2 |                                                   |
|   0          0          |                                                   |
|   0          0          |                                                   |
|   0          0          |                                                   |
|   s2+st      s2+2st+t2  |                                                   |
|                                                                             |
|                       10                                                    |
|--------------------- S   : 3                                                |
|       0          |                                                          |
|       0          |                                                          |
|2st-t2 0          |                                                          |
|       -s2+2st-t2 |                                                          |
|       0          |                                                          |
|st     -s2+t2     |                                                          |
|       0          |                                                          |
|st     -s2-2st-t2 |                                                          |
|       0          |                                                          |
|       0          |                                                          |
|       0          |                                                          |
|       0          |                                                          |
|       t          |                                                          |
+-----------------------------------------------------------------------------+
|i14 : prune HH g                                                             |
|                                                                             |
|o14 = 0 : cokernel | t2 st s2 | <--------- cokernel | t2 st s2 | : 0         |
|                                   | 1 |                                     |
|                                                                             |
|o14 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+

See also
========

  * RingMap ** Complex -- tensor a complex along
    a ring map
  * RingMap ComplexMap -- apply a ring map to a map
    of complexes

Ways to use this method:
========================

  * "ComplexMap ** Ring"
  * "ComplexMap ** RingMap"
  * "Ring ** ComplexMap"
  * RingMap ** ComplexMap -- tensor a map of
    complexes along a ring map

RingMap Complex -- apply a ring map
***********************************

Synopsis
========

  * Operator: SPACE (Macaulay2Doc),
  * Usage:
        phi C
  * Inputs:
      * phi, a ring map (Macaulay2Doc), whose source is a ring
        $R$, and whose target is a ring $S$
      * C, a complex, over the ring $R$
  * Outputs:
      * a complex, over the ring $S$

Description
===========

We illustrate the image of a complex under a ring map.

+---------------------------------------------------------------------------+
|i1 : R = QQ[x,y,z]                                                         |
|                                                                           |
|o1 = R                                                                     |
|                                                                           |
|o1 : PolynomialRing                                                        |
+---------------------------------------------------------------------------+
|i2 : S = QQ[s,t]                                                           |
|                                                                           |
|o2 = S                                                                     |
|                                                                           |
|o2 : PolynomialRing                                                        |
+---------------------------------------------------------------------------+
|i3 : phi = map(S, R, {s, s+t, t})                                          |
|                                                                           |
|o3 = map (S, R, {s, s + t, t})                                             |
|                                                                           |
|o3 : RingMap S <--- R                                                      |
+---------------------------------------------------------------------------+
|i4 : I = ideal(x^3, x^2*y, x*y^4, y*z^5)                                   |
|                                                                           |
|             3   2      4     5                                            |
|o4 = ideal (x , x y, x*y , y*z )                                           |
|                                                                           |
|o4 : Ideal of R                                                            |
+---------------------------------------------------------------------------+
|i5 : C = freeResolution I                                                  |
|                                                                           |
|      1      4      4      1                                               |
|o5 = R  <-- R  <-- R  <-- R                                                |
|                                                                           |
|     0      1      2      3                                                |
|                                                                           |
|o5 : Complex                                                               |
+---------------------------------------------------------------------------+
|i6 : D = phi C                                                             |
|                                                                           |
|      1      4      4      1                                               |
|o6 = S  <-- S  <-- S  <-- S                                                |
|                                                                           |
|     0      1      2      3                                                |
|                                                                           |
|o6 : Complex                                                               |
+---------------------------------------------------------------------------+
|i7 : isWellDefined D                                                       |
|                                                                           |
|o7 = true                                                                  |
+---------------------------------------------------------------------------+
|i8 : dd^D                                                                  |
|                                                                           |
|          1                                                    4           |
|o8 = 0 : S  <------------------------------------------------ S  : 1       |
|               | s3 s3+s2t s5+4s4t+6s3t2+4s2t3+st4 st5+t6 |                |
|                                                                           |
|          4                                                           4    |
|     1 : S  <------------------------------------------------------- S  : 2|
|               {3} | -s-t 0                0   0                 |         |
|               {3} | s    -s3-3s2t-3st2-t3 -t5 0                 |         |
|               {5} | 0    s                0   -t5               |         |
|               {6} | 0    0                s2  s4+3s3t+3s2t2+st3 |         |
|                                                                           |
|          4                                 1                              |
|     2 : S  <----------------------------- S  : 3                          |
|               {4}  | 0                |                                   |
|               {6}  | t5               |                                   |
|               {8}  | -s3-3s2t-3st2-t3 |                                   |
|               {10} | s                |                                   |
|                                                                           |
|o8 : ComplexMap                                                            |
+---------------------------------------------------------------------------+
|i9 : prune HH D                                                            |
|                                                                           |
|o9 = cokernel | s2t s3 st4 t6 | <-- cokernel {7} | s t3 |                  |
|                                                                           |
|     0                              1                                      |
|                                                                           |
|o9 : Complex                                                               |
+---------------------------------------------------------------------------+

When the ring map doesn't preserve homogeneity, the DegreeMap (Macaulay2Doc),
option is needed to determine the degrees of the image
free modules in the complex.

+-----------------------------------------------------------------------------+
|i10 : R = ZZ/101[a..d]                                                       |
|                                                                             |
|o10 = R                                                                      |
|                                                                             |
|o10 : PolynomialRing                                                         |
+-----------------------------------------------------------------------------+
|i11 : S = ZZ/101[s,t]                                                        |
|                                                                             |
|o11 = S                                                                      |
|                                                                             |
|o11 : PolynomialRing                                                         |
+-----------------------------------------------------------------------------+
|i12 : phi = map(S, R, {s^4, s^3*t, s*t^3, t^4}, DegreeMap => i -> 4*i)       |
|                                                                             |
|                   4   3      3   4                                          |
|o12 = map (S, R, {s , s t, s*t , t })                                        |
|                                                                             |
|o12 : RingMap S <--- R                                                       |
+-----------------------------------------------------------------------------+
|i13 : C = freeResolution coker vars R                                        |
|                                                                             |
|       1      4      6      4      1                                         |
|o13 = R  <-- R  <-- R  <-- R  <-- R                                          |
|                                                                             |
|      0      1      2      3      4                                          |
|                                                                             |
|o13 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i14 : D = phi C                                                              |
|                                                                             |
|       1      4      6      4      1                                         |
|o14 = S  <-- S  <-- S  <-- S  <-- S                                          |
|                                                                             |
|      0      1      2      3      4                                          |
|                                                                             |
|o14 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i15 : assert isWellDefined D                                                 |
+-----------------------------------------------------------------------------+
|i16 : assert isHomogeneous D                                                 |
+-----------------------------------------------------------------------------+
|i17 : prune HH D                                                             |
|                                                                             |
|o17 = cokernel | t4 st3 s3t s4 | <-- cokernel {5} | s3 0  t3 0   0  st2 | <--|
|                                              {5} | 0  t3 s3 s2t 0  0   |    |
|      0                                       {6} | 0  0  0  t2  st s2  |    |
|                                                                             |
|                                     1                                       |
|                                                                             |
|o17 : Complex                                                                |
|-----------------------------------------------------------------------------|
|cokernel {10} | s2 0 0 t2 |                                                  |
|         {11} | t  s 0 0  |                                                  |
|         {11} | 0  0 t s  |                                                  |
|                                                                             |
|2                                                                            |
+-----------------------------------------------------------------------------+

Caveat
======

Every term in the complex must be free or a submodule of a free module.
Otherwise, use tensor(RingMap,Complex).

See also
========

  * RingMap ComplexMap -- apply a ring map to a map
    of complexes
  * RingMap ** Complex -- tensor a complex along
    a ring map

Ways to use this method:
========================

  * RingMap Complex -- apply a ring map

RingMap ComplexMap -- apply a ring map to a map of complexes
************************************************************

Synopsis
========

  * Operator: SPACE (Macaulay2Doc),
  * Usage:
        phi f
  * Inputs:
      * phi, a ring map (Macaulay2Doc), whose source is a ring
        $R$, and whose target is a ring $S$
      * f, a map of complexes, over the ring $R$
  * Outputs:
      * a map of complexes, over the ring $S$

Description
===========

We illustrate the image of a complex map along a ring map.

+-----------------------------------------------------------------------------+
|i1 : R = QQ[a,b,c,d];                                                        |
+-----------------------------------------------------------------------------+
|i2 : S = QQ[s,t];                                                            |
+-----------------------------------------------------------------------------+
|i3 : phi = map(S, R, {s, s+t, t, s-t})                                       |
|                                                                             |
|o3 = map (S, R, {s, s + t, t, s - t})                                        |
|                                                                             |
|o3 : RingMap S <--- R                                                        |
+-----------------------------------------------------------------------------+
|i4 : I = ideal(a*b, b*c, c*d)                                                |
|                                                                             |
|o4 = ideal (a*b, b*c, c*d)                                                   |
|                                                                             |
|o4 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i5 : J = I + ideal(a^2, b^2, c^2, d^2)                                       |
|                                                                             |
|                            2   2   2   2                                    |
|o5 = ideal (a*b, b*c, c*d, a , b , c , d )                                   |
|                                                                             |
|o5 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i6 : CI = freeResolution I                                                   |
|                                                                             |
|      1      3      2                                                        |
|o6 = R  <-- R  <-- R                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o6 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i7 : CJ = freeResolution J                                                   |
|                                                                             |
|      1      7      13      10      3                                        |
|o7 = R  <-- R  <-- R   <-- R   <-- R                                         |
|                                                                             |
|     0      1      2       3       4                                         |
|                                                                             |
|o7 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i8 : f = extend(CJ, CI, map(CJ_0, CI_0, 1))                                  |
|                                                                             |
|          1             1                                                    |
|o8 = 0 : R  <--------- R  : 0                                                |
|               | 1 |                                                         |
|                                                                             |
|          7                     3                                            |
|     1 : R  <----------------- R  : 1                                        |
|               {2} | 0 0 0 |                                                 |
|               {2} | 1 0 0 |                                                 |
|               {2} | 0 0 0 |                                                 |
|               {2} | 0 1 0 |                                                 |
|               {2} | 0 0 0 |                                                 |
|               {2} | 0 0 1 |                                                 |
|               {2} | 0 0 0 |                                                 |
|                                                                             |
|          13                   2                                             |
|     2 : R   <--------------- R  : 2                                         |
|                {3} | 0 0 |                                                  |
|                {3} | 0 0 |                                                  |
|                {3} | 1 0 |                                                  |
|                {3} | 0 0 |                                                  |
|                {3} | 0 0 |                                                  |
|                {3} | 0 1 |                                                  |
|                {3} | 0 0 |                                                  |
|                {3} | 0 0 |                                                  |
|                {4} | 0 0 |                                                  |
|                {4} | 0 0 |                                                  |
|                {4} | 0 0 |                                                  |
|                {4} | 0 0 |                                                  |
|                {4} | 0 0 |                                                  |
|                                                                             |
|o8 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i9 : assert isWellDefined f                                                  |
+-----------------------------------------------------------------------------+
|i10 : g = phi f                                                              |
|                                                                             |
|           1             1                                                   |
|o10 = 0 : S  <--------- S  : 0                                               |
|                | 1 |                                                        |
|                                                                             |
|           7                     3                                           |
|      1 : S  <----------------- S  : 1                                       |
|                {2} | 0 0 0 |                                                |
|                {2} | 1 0 0 |                                                |
|                {2} | 0 0 0 |                                                |
|                {2} | 0 1 0 |                                                |
|                {2} | 0 0 0 |                                                |
|                {2} | 0 0 1 |                                                |
|                {2} | 0 0 0 |                                                |
|                                                                             |
|           13                   2                                            |
|      2 : S   <--------------- S  : 2                                        |
|                 {3} | 0 0 |                                                 |
|                 {3} | 0 0 |                                                 |
|                 {3} | 1 0 |                                                 |
|                 {3} | 0 0 |                                                 |
|                 {3} | 0 0 |                                                 |
|                 {3} | 0 1 |                                                 |
|                 {3} | 0 0 |                                                 |
|                 {3} | 0 0 |                                                 |
|                 {4} | 0 0 |                                                 |
|                 {4} | 0 0 |                                                 |
|                 {4} | 0 0 |                                                 |
|                 {4} | 0 0 |                                                 |
|                 {4} | 0 0 |                                                 |
|                                                                             |
|o10 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i11 : assert isWellDefined g                                                 |
+-----------------------------------------------------------------------------+
|i12 : dd^(source g)                                                          |
|                                                                             |
|           1                             3                                   |
|o12 = 0 : S  <------------------------- S  : 1                               |
|                | s2+st st+t2 st-t2 |                                        |
|                                                                             |
|           3                       2                                         |
|      1 : S  <------------------- S  : 2                                     |
|                {2} | -t 0    |                                              |
|                {2} | s  -s+t |                                              |
|                {2} | 0  s+t  |                                              |
|                                                                             |
|o12 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i13 : dd^(target g)                                                          |
|                                                                             |
|           1                                                       7         |
|o13 = 0 : S  <--------------------------------------------------- S  : 1     |
|                | s2 s2+st s2+2st+t2 st+t2 t2 st-t2 s2-2st+t2 |              |
|                                                                             |
|           7                                                                 |
|      1 : S  <---------------------------------------------------------------|
|                {2} | -s-t 0    0  0   0   0    0    0    -t2 -st+t2 -s2+2st-|
|                {2} | s    -s-t -t 0   0   0    0    0    0   0      0       |
|                {2} | 0    s    0  -t  0   0    0    0    0   0      0       |
|                {2} | 0    0    s  s+t -t  -s+t 0    0    0   0      0       |
|                {2} | 0    0    0  0   s+t 0    -s+t 0    s2  0      0       |
|                {2} | 0    0    0  0   0   s+t  t    -s+t 0   s2     0       |
|                {2} | 0    0    0  0   0   0    0    t    0   0      s2      |
|                                                                             |
|           13                                                                |
|      2 : S   <--------------------------------------------------------------|
|                 {3} | 0    0   -t2 -st+t2 0    s2-2st+t2 0         0    0   |
|                 {3} | t    0   0   0      0    0         s2-2st+t2 0    0   |
|                 {3} | -s-t 0   -st -s2+st 0    0         0         0    -s2+|
|                 {3} | s    0   0   0      0    0         0         0    0   |
|                 {3} | 0    s-t -s2 0      0    0         0         0    0   |
|                 {3} | 0    -t  0   -s2    0    0         0         0    -s2+|
|                 {3} | 0    s+t 0   0      -s2  0         0         0    0   |
|                 {3} | 0    0   0   0      0    0         0         -s2  -s2-|
|                 {4} | 0    0   s+t 0      -s+t 0         0         0    0   |
|                 {4} | 0    0   0   s+t    t    0         0         -s+t 0   |
|                 {4} | 0    0   0   0      0    -s-t      0         t    0   |
|                 {4} | 0    0   0   0      0    s         -s-t      0    t   |
|                 {4} | 0    0   0   0      0    0         s         0    0   |
|                                                                             |
|           10                                  3                             |
|      3 : S   <------------------------------ S  : 4                         |
|                 {4} | 0   0    s2-2st+t2 |                                  |
|                 {4} | s2  0    0         |                                  |
|                 {5} | s-t 0    0         |                                  |
|                 {5} | -t  -s+t 0         |                                  |
|                 {5} | s+t 0    0         |                                  |
|                 {5} | 0   -t   0         |                                  |
|                 {5} | 0   0    -t        |                                  |
|                 {5} | 0   -s-t 0         |                                  |
|                 {5} | 0   s    -s-t      |                                  |
|                 {5} | 0   0    s         |                                  |
|                                                                             |
|o13 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                              13                                             |
|---------------------------- S   : 2                                         |
|t2 0          0          |                                                   |
|   -s2+2st-t2 0          |                                                   |
|   0          -s2+2st-t2 |                                                   |
|   0          0          |                                                   |
|   0          0          |                                                   |
|   0          0          |                                                   |
|   s2+st      s2+2st+t2  |                                                   |
|                                                                             |
|                       10                                                    |
|--------------------- S   : 3                                                |
|       0          |                                                          |
|       0          |                                                          |
|2st-t2 0          |                                                          |
|       -s2+2st-t2 |                                                          |
|       0          |                                                          |
|st     -s2+t2     |                                                          |
|       0          |                                                          |
|st     -s2-2st-t2 |                                                          |
|       0          |                                                          |
|       0          |                                                          |
|       0          |                                                          |
|       0          |                                                          |
|       t          |                                                          |
+-----------------------------------------------------------------------------+
|i14 : prune HH g                                                             |
|                                                                             |
|o14 = 0 : cokernel | t2 st s2 | <--------- cokernel | t2 st s2 | : 0         |
|                                   | 1 |                                     |
|                                                                             |
|o14 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+

See also
========

  * RingMap Complex -- apply a ring map
  * RingMap ** ComplexMap -- tensor a map of
    complexes along a ring map

Ways to use this method:
========================

  * RingMap ComplexMap -- apply a ring map to a map
    of complexes

source(ComplexMap) -- get the source of a map of chain complexes
****************************************************************

Synopsis
========

  * Function: source (Macaulay2Doc),
  * Usage:
        C = source f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * C, a complex,

Description
===========

Given a complex map $f : C \to D$ this method returns the chain complex $C$.

+----------------------------------------------+
|i1 : R = ZZ/101[a..d]                         |
|                                              |
|o1 = R                                        |
|                                              |
|o1 : PolynomialRing                           |
+----------------------------------------------+
|i2 : I = ideal(a^2, b^2, c^2)                 |
|                                              |
|             2   2   2                        |
|o2 = ideal (a , b , c )                       |
|                                              |
|o2 : Ideal of R                               |
+----------------------------------------------+
|i3 : J = I + ideal(a*b*c)                     |
|                                              |
|             2   2   2                        |
|o3 = ideal (a , b , c , a*b*c)                |
|                                              |
|o3 : Ideal of R                               |
+----------------------------------------------+
|i4 : FI = freeResolution I                    |
|                                              |
|      1      3      3      1                  |
|o4 = R  <-- R  <-- R  <-- R                   |
|                                              |
|     0      1      2      3                   |
|                                              |
|o4 : Complex                                  |
+----------------------------------------------+
|i5 : FJ = freeResolution J                    |
|                                              |
|      1      4      6      3                  |
|o5 = R  <-- R  <-- R  <-- R                   |
|                                              |
|     0      1      2      3                   |
|                                              |
|o5 : Complex                                  |
+----------------------------------------------+
|i6 : f = randomComplexMap(FJ, FI, Cycle=>true)|
|                                              |
|          1              1                    |
|o6 = 0 : R  <---------- R  : 0                |
|               | 24 |                         |
|                                              |
|          4                        3          |
|     1 : R  <-------------------- R  : 1      |
|               {2} | 24 0  0  |               |
|               {2} | 0  24 0  |               |
|               {2} | 0  0  24 |               |
|               {3} | 0  0  0  |               |
|                                              |
|          6                        3          |
|     2 : R  <-------------------- R  : 2      |
|               {4} | 24 0  0  |               |
|               {4} | 0  0  0  |               |
|               {4} | 0  0  0  |               |
|               {4} | 0  24 0  |               |
|               {4} | 0  0  0  |               |
|               {4} | 0  0  24 |               |
|                                              |
|          3                    1              |
|     3 : R  <---------------- R  : 3          |
|               {5} | 24c  |                   |
|               {5} | -24b |                   |
|               {5} | 24a  |                   |
|                                              |
|o6 : ComplexMap                               |
+----------------------------------------------+
|i7 : source f                                 |
|                                              |
|      1      3      3      1                  |
|o7 = R  <-- R  <-- R  <-- R                   |
|                                              |
|     0      1      2      3                   |
|                                              |
|o7 : Complex                                  |
+----------------------------------------------+
|i8 : assert isWellDefined f                   |
+----------------------------------------------+
|i9 : assert isComplexMorphism f               |
+----------------------------------------------+
|i10 : assert(source f == FI)                  |
+----------------------------------------------+
|i11 : assert(target f == FJ)                  |
+----------------------------------------------+

The differential in a complex is a map of chain complexes.

+------------------------------------+
|i12 : kk = coker vars R             |
|                                    |
|o12 = cokernel | a b c d |          |
|                                    |
|                             1      |
|o12 : R-module, quotient of R       |
+------------------------------------+
|i13 : F = freeResolution kk         |
|                                    |
|       1      4      6      4      1|
|o13 = R  <-- R  <-- R  <-- R  <-- R |
|                                    |
|      0      1      2      3      4 |
|                                    |
|o13 : Complex                       |
+------------------------------------+
|i14 : source dd^F == F              |
|                                    |
|o14 = true                          |
+------------------------------------+
|i15 : target dd^F == F              |
|                                    |
|o15 = true                          |
+------------------------------------+
|i16 : degree dd^F == -1             |
|                                    |
|o16 = true                          |
+------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * target(ComplexMap) -- get the target of a
    map of chain complexes
  * freeResolution(Ideal) -- compute a free resolution
    of a module or ideal
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes

Ways to use this method:
========================

  * source(ComplexMap) -- get the source of a
    map of chain complexes

sum(Complex) -- make the direct sum of all terms
************************************************

Synopsis
========

  * Function: sum (Macaulay2Doc),
  * Usage:
        sum C
        sum f
  * Inputs:
      * C, a complex, or f, a map of complexes,
  * Outputs:
      * a module (Macaulay2Doc), or a matrix (Macaulay2Doc),
        if the input is a complex map

Description
===========

This is the forgetful functor from the category of chain complexes to the
category of modules. A chain complex $C$ is sent to the direct sum $\bigoplus_i
C_i$ of its terms. A map of chain complexes $f \colon C \to D$ is sent to the
direct sum $\bigoplus_i f_i \colon \bigoplus_i C_i \to \bigoplus_i D_i$.

+------------------------------------------------+
|i1 : S = ZZ/101[a,b,c];                         |
+------------------------------------------------+
|i2 : C = koszulComplex {a,b,c}                  |
|                                                |
|      1      3      3      1                    |
|o2 = S  <-- S  <-- S  <-- S                     |
|                                                |
|     0      1      2      3                     |
|                                                |
|o2 : Complex                                    |
+------------------------------------------------+
|i3 : sum C                                      |
|                                                |
|      8                                         |
|o3 = S                                          |
|                                                |
|o3 : S-module, free, degrees {0..1, 2:1, 3:2, 3}|
+------------------------------------------------+
|i4 : assert(rank sum C == 2^3)                  |
+------------------------------------------------+
+-----------------------------------------------------------------------------+
|i5 : f = randomComplexMap(C, C, InternalDegree => 1, Cycle => true)          |
|                                                                             |
|          1                       1                                          |
|o5 = 0 : S  <------------------- S  : 0                                      |
|               | -5a-27b-40c |                                               |
|                                                                             |
|          3                                                  3               |
|     1 : S  <---------------------------------------------- S  : 1           |
|               {1} | -5a-46b+42c -7b+24c    29b+9c      |                    |
|               {1} | 19a-8c      2a-27b-14c -29a-30c    |                    |
|               {1} | 19a+8b      -24a-26b   -14a+3b-40c |                    |
|                                                                             |
|          3                                                  3               |
|     2 : S  <---------------------------------------------- S  : 2           |
|               {2} | 2a-46b-30c -29a-10c     -29b+22c   |                    |
|               {2} | -24a-29b   -14a-36b+42c -38b+24c   |                    |
|               {2} | -16a-8b    39a-8c       24a+3b-14c |                    |
|                                                                             |
|          1                           1                                      |
|     3 : S  <----------------------- S  : 3                                  |
|               {3} | 24a-36b-30c |                                           |
|                                                                             |
|o5 : ComplexMap                                                              |
+-----------------------------------------------------------------------------+
|i6 : g = sum f                                                               |
|                                                                             |
|o6 = {0} | -5a-27b-40c 0           0          0           0                  |
|     {1} | 0           -5a-46b+42c -7b+24c    29b+9c      0                  |
|     {1} | 0           19a-8c      2a-27b-14c -29a-30c    0                  |
|     {1} | 0           19a+8b      -24a-26b   -14a+3b-40c 0                  |
|     {2} | 0           0           0          0           2a-46b-30c         |
|     {2} | 0           0           0          0           -24a-29b           |
|     {2} | 0           0           0          0           -16a-8b            |
|     {3} | 0           0           0          0           0                  |
|     ------------------------------------------------------------------------|
|     0            0          0           |                                   |
|     0            0          0           |                                   |
|     0            0          0           |                                   |
|     0            0          0           |                                   |
|     -29a-10c     -29b+22c   0           |                                   |
|     -14a-36b+42c -38b+24c   0           |                                   |
|     39a-8c       24a+3b-14c 0           |                                   |
|     0            0          24a-36b-30c |                                   |
|                                                                             |
|             8       8                                                       |
|o6 : Matrix S  <--- S                                                        |
+-----------------------------------------------------------------------------+
|i7 : assert(g^2 === sum f^2)                                                 |
+-----------------------------------------------------------------------------+
|i8 : assert(target g === sum target f)                                       |
+-----------------------------------------------------------------------------+
|i9 : assert(source g === sum source f)                                       |
+-----------------------------------------------------------------------------+
|i10 : h = sum dd^C                                                           |
|                                                                             |
|o10 = {0} | 0 a b c 0  0  0  0  |                                            |
|      {1} | 0 0 0 0 -b -c 0  0  |                                            |
|      {1} | 0 0 0 0 a  0  -c 0  |                                            |
|      {1} | 0 0 0 0 0  a  b  0  |                                            |
|      {2} | 0 0 0 0 0  0  0  c  |                                            |
|      {2} | 0 0 0 0 0  0  0  -b |                                            |
|      {2} | 0 0 0 0 0  0  0  a  |                                            |
|      {3} | 0 0 0 0 0  0  0  0  |                                            |
|                                                                             |
|              8       8                                                      |
|o10 : Matrix S  <--- S                                                       |
+-----------------------------------------------------------------------------+
|i11 : assert(h^2 == 0)                                                       |
+-----------------------------------------------------------------------------+

See also
========

  * Basic invariants and properties, --
    information about accessing basic features
  * directSum(Complex) -- direct sum of
    complexes
  * koszulComplex -- makes the Koszul complex
  * randomComplexMap -- a
    random map of chain complexes

Ways to use this method:
========================

  * sum(Complex) -- make the direct sum of all terms
  * "sum(ComplexMap)"

target(ComplexMap) -- get the target of a map of chain complexes
****************************************************************

Synopsis
========

  * Function: target (Macaulay2Doc),
  * Usage:
        C = target f
  * Inputs:
      * f, a map of complexes,
  * Outputs:
      * C, a complex,

Description
===========

Given a complex map $f : C \to D$ this method returns the chain complex $D$.

+----------------------------------------------+
|i1 : R = ZZ/101[a..d]                         |
|                                              |
|o1 = R                                        |
|                                              |
|o1 : PolynomialRing                           |
+----------------------------------------------+
|i2 : I = ideal(a^2, b^2, c^2)                 |
|                                              |
|             2   2   2                        |
|o2 = ideal (a , b , c )                       |
|                                              |
|o2 : Ideal of R                               |
+----------------------------------------------+
|i3 : J = I + ideal(a*b*c)                     |
|                                              |
|             2   2   2                        |
|o3 = ideal (a , b , c , a*b*c)                |
|                                              |
|o3 : Ideal of R                               |
+----------------------------------------------+
|i4 : FI = freeResolution I                    |
|                                              |
|      1      3      3      1                  |
|o4 = R  <-- R  <-- R  <-- R                   |
|                                              |
|     0      1      2      3                   |
|                                              |
|o4 : Complex                                  |
+----------------------------------------------+
|i5 : FJ = freeResolution J                    |
|                                              |
|      1      4      6      3                  |
|o5 = R  <-- R  <-- R  <-- R                   |
|                                              |
|     0      1      2      3                   |
|                                              |
|o5 : Complex                                  |
+----------------------------------------------+
|i6 : f = randomComplexMap(FJ, FI, Cycle=>true)|
|                                              |
|          1              1                    |
|o6 = 0 : R  <---------- R  : 0                |
|               | 24 |                         |
|                                              |
|          4                        3          |
|     1 : R  <-------------------- R  : 1      |
|               {2} | 24 0  0  |               |
|               {2} | 0  24 0  |               |
|               {2} | 0  0  24 |               |
|               {3} | 0  0  0  |               |
|                                              |
|          6                        3          |
|     2 : R  <-------------------- R  : 2      |
|               {4} | 24 0  0  |               |
|               {4} | 0  0  0  |               |
|               {4} | 0  0  0  |               |
|               {4} | 0  24 0  |               |
|               {4} | 0  0  0  |               |
|               {4} | 0  0  24 |               |
|                                              |
|          3                    1              |
|     3 : R  <---------------- R  : 3          |
|               {5} | 24c  |                   |
|               {5} | -24b |                   |
|               {5} | 24a  |                   |
|                                              |
|o6 : ComplexMap                               |
+----------------------------------------------+
|i7 : target f                                 |
|                                              |
|      1      4      6      3                  |
|o7 = R  <-- R  <-- R  <-- R                   |
|                                              |
|     0      1      2      3                   |
|                                              |
|o7 : Complex                                  |
+----------------------------------------------+
|i8 : assert isWellDefined f                   |
+----------------------------------------------+
|i9 : assert isComplexMorphism f               |
+----------------------------------------------+
|i10 : assert(target f == FJ)                  |
+----------------------------------------------+
|i11 : assert(source f == FI)                  |
+----------------------------------------------+

The differential in a complex is a map of chain complexes.

+------------------------------------+
|i12 : kk = coker vars R             |
|                                    |
|o12 = cokernel | a b c d |          |
|                                    |
|                             1      |
|o12 : R-module, quotient of R       |
+------------------------------------+
|i13 : F = freeResolution kk         |
|                                    |
|       1      4      6      4      1|
|o13 = R  <-- R  <-- R  <-- R  <-- R |
|                                    |
|      0      1      2      3      4 |
|                                    |
|o13 : Complex                       |
+------------------------------------+
|i14 : target dd^F == F              |
|                                    |
|o14 = true                          |
+------------------------------------+
|i15 : source dd^F == F              |
|                                    |
|o15 = true                          |
+------------------------------------+
|i16 : degree dd^F == -1             |
|                                    |
|o16 = true                          |
+------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * source(ComplexMap) -- get the source of a
    map of chain complexes
  * freeResolution(Ideal) -- compute a free resolution
    of a module or ideal
  * randomComplexMap(Complex,Complex)
    -- a random map of chain complexes

Ways to use this method:
========================

  * target(ComplexMap) -- get the target of a
    map of chain complexes

tensorAssociativity(Complex,Complex,Complex) -- make the canonical isomorphism arising from associativity
*********************************************************************************************************

Synopsis
========

  * Function: tensorAssociativity (Macaulay2Doc),
  * Usage:
        tensorAssociativity(C, D, E)
  * Inputs:
      * C, a complex,
      * D, a complex,
      * E, a complex,
  * Outputs:
      * a map of complexes, which is an isomorphism from C
        ** (D ** E) to (C ** D) ** E

Description
===========

The associativity of tensor products of modules induces the associativity of
tensor products of chain complexes. This method implements this isomorphism for
chain complexes.

Using two term complexes of small rank, we see that this isomorphism need not
be the identity map.

+--------------------------------------------------------------+
|i1 : S = ZZ/101[x_0..x_11]                                    |
|                                                              |
|o1 = S                                                        |
|                                                              |
|o1 : PolynomialRing                                           |
+--------------------------------------------------------------+
|i2 : C = complex{genericMatrix(S,x_0,2,1)}                    |
|                                                              |
|      2      1                                                |
|o2 = S  <-- S                                                 |
|                                                              |
|     0      1                                                 |
|                                                              |
|o2 : Complex                                                  |
+--------------------------------------------------------------+
|i3 : D = complex{genericMatrix(S,x_4,1,2)}                    |
|                                                              |
|      1      2                                                |
|o3 = S  <-- S                                                 |
|                                                              |
|     0      1                                                 |
|                                                              |
|o3 : Complex                                                  |
+--------------------------------------------------------------+
|i4 : E = complex{genericMatrix(S,x_8,2,2)}                    |
|                                                              |
|      2      2                                                |
|o4 = S  <-- S                                                 |
|                                                              |
|     0      1                                                 |
|                                                              |
|o4 : Complex                                                  |
+--------------------------------------------------------------+
|i5 : F = (C ** D) ** E                                        |
|                                                              |
|      4      14      14      4                                |
|o5 = S  <-- S   <-- S   <-- S                                 |
|                                                              |
|     0      1       2       3                                 |
|                                                              |
|o5 : Complex                                                  |
+--------------------------------------------------------------+
|i6 : G = C ** (D ** E)                                        |
|                                                              |
|      4      14      14      4                                |
|o6 = S  <-- S   <-- S   <-- S                                 |
|                                                              |
|     0      1       2       3                                 |
|                                                              |
|o6 : Complex                                                  |
+--------------------------------------------------------------+
|i7 : f = tensorAssociativity(C,D,E)                           |
|                                                              |
|          4                   4                               |
|o7 = 0 : S  <--------------- S  : 0                           |
|               | 1 0 0 0 |                                    |
|               | 0 1 0 0 |                                    |
|               | 0 0 1 0 |                                    |
|               | 0 0 0 1 |                                    |
|                                                              |
|          14                                           14     |
|     1 : S   <--------------------------------------- S   : 1 |
|                {1} | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 |           |
|                {1} | 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |           |
|                {1} | 0 0 0 0 0 0 1 0 0 0 0 0 0 0 |           |
|                {1} | 0 0 0 0 0 0 0 1 0 0 0 0 0 0 |           |
|                {1} | 0 0 1 0 0 0 0 0 0 0 0 0 0 0 |           |
|                {1} | 0 0 0 1 0 0 0 0 0 0 0 0 0 0 |           |
|                {1} | 0 0 0 0 1 0 0 0 0 0 0 0 0 0 |           |
|                {1} | 0 0 0 0 0 1 0 0 0 0 0 0 0 0 |           |
|                {1} | 0 0 0 0 0 0 0 0 1 0 0 0 0 0 |           |
|                {1} | 0 0 0 0 0 0 0 0 0 1 0 0 0 0 |           |
|                {1} | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 |           |
|                {1} | 0 0 0 0 0 0 0 0 0 0 0 1 0 0 |           |
|                {1} | 0 0 0 0 0 0 0 0 0 0 0 0 1 0 |           |
|                {1} | 0 0 0 0 0 0 0 0 0 0 0 0 0 1 |           |
|                                                              |
|          14                                           14     |
|     2 : S   <--------------------------------------- S   : 2 |
|                {2} | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 |           |
|                {2} | 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |           |
|                {2} | 0 0 1 0 0 0 0 0 0 0 0 0 0 0 |           |
|                {2} | 0 0 0 1 0 0 0 0 0 0 0 0 0 0 |           |
|                {2} | 0 0 0 0 1 0 0 0 0 0 0 0 0 0 |           |
|                {2} | 0 0 0 0 0 1 0 0 0 0 0 0 0 0 |           |
|                {2} | 0 0 0 0 0 0 1 0 0 0 0 0 0 0 |           |
|                {2} | 0 0 0 0 0 0 0 1 0 0 0 0 0 0 |           |
|                {2} | 0 0 0 0 0 0 0 0 1 0 0 0 0 0 |           |
|                {2} | 0 0 0 0 0 0 0 0 0 1 0 0 0 0 |           |
|                {2} | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 |           |
|                {2} | 0 0 0 0 0 0 0 0 0 0 0 1 0 0 |           |
|                {2} | 0 0 0 0 0 0 0 0 0 0 0 0 1 0 |           |
|                {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 1 |           |
|                                                              |
|          4                       4                           |
|     3 : S  <------------------- S  : 3                       |
|               {3} | 1 0 0 0 |                                |
|               {3} | 0 1 0 0 |                                |
|               {3} | 0 0 1 0 |                                |
|               {3} | 0 0 0 1 |                                |
|                                                              |
|o7 : ComplexMap                                               |
+--------------------------------------------------------------+
|i8 : assert isWellDefined f                                   |
+--------------------------------------------------------------+
|i9 : assert(source f === G)                                   |
+--------------------------------------------------------------+
|i10 : assert(target f === F)                                  |
+--------------------------------------------------------------+
|i11 : f_1                                                     |
|                                                              |
|o11 = {1} | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 |                     |
|      {1} | 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |                     |
|      {1} | 0 0 0 0 0 0 1 0 0 0 0 0 0 0 |                     |
|      {1} | 0 0 0 0 0 0 0 1 0 0 0 0 0 0 |                     |
|      {1} | 0 0 1 0 0 0 0 0 0 0 0 0 0 0 |                     |
|      {1} | 0 0 0 1 0 0 0 0 0 0 0 0 0 0 |                     |
|      {1} | 0 0 0 0 1 0 0 0 0 0 0 0 0 0 |                     |
|      {1} | 0 0 0 0 0 1 0 0 0 0 0 0 0 0 |                     |
|      {1} | 0 0 0 0 0 0 0 0 1 0 0 0 0 0 |                     |
|      {1} | 0 0 0 0 0 0 0 0 0 1 0 0 0 0 |                     |
|      {1} | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 |                     |
|      {1} | 0 0 0 0 0 0 0 0 0 0 0 1 0 0 |                     |
|      {1} | 0 0 0 0 0 0 0 0 0 0 0 0 1 0 |                     |
|      {1} | 0 0 0 0 0 0 0 0 0 0 0 0 0 1 |                     |
|                                                              |
|              14       14                                     |
|o11 : Matrix S   <--- S                                       |
+--------------------------------------------------------------+
|i12 : assert(f_1 != id_(source f_1))                          |
+--------------------------------------------------------------+
|i13 : assert(prune ker f == 0)                                |
+--------------------------------------------------------------+
|i14 : assert(prune coker f == 0)                              |
+--------------------------------------------------------------+
|i15 : g = f^-1                                                |
|                                                              |
|           4                   4                              |
|o15 = 0 : S  <--------------- S  : 0                          |
|                | 1 0 0 0 |                                   |
|                | 0 1 0 0 |                                   |
|                | 0 0 1 0 |                                   |
|                | 0 0 0 1 |                                   |
|                                                              |
|           14                                           14    |
|      1 : S   <--------------------------------------- S   : 1|
|                 {1} | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 |          |
|                 {1} | 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |          |
|                 {1} | 0 0 0 0 1 0 0 0 0 0 0 0 0 0 |          |
|                 {1} | 0 0 0 0 0 1 0 0 0 0 0 0 0 0 |          |
|                 {1} | 0 0 0 0 0 0 1 0 0 0 0 0 0 0 |          |
|                 {1} | 0 0 0 0 0 0 0 1 0 0 0 0 0 0 |          |
|                 {1} | 0 0 1 0 0 0 0 0 0 0 0 0 0 0 |          |
|                 {1} | 0 0 0 1 0 0 0 0 0 0 0 0 0 0 |          |
|                 {1} | 0 0 0 0 0 0 0 0 1 0 0 0 0 0 |          |
|                 {1} | 0 0 0 0 0 0 0 0 0 1 0 0 0 0 |          |
|                 {1} | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 |          |
|                 {1} | 0 0 0 0 0 0 0 0 0 0 0 1 0 0 |          |
|                 {1} | 0 0 0 0 0 0 0 0 0 0 0 0 1 0 |          |
|                 {1} | 0 0 0 0 0 0 0 0 0 0 0 0 0 1 |          |
|                                                              |
|           14                                           14    |
|      2 : S   <--------------------------------------- S   : 2|
|                 {2} | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 |          |
|                 {2} | 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |          |
|                 {2} | 0 0 1 0 0 0 0 0 0 0 0 0 0 0 |          |
|                 {2} | 0 0 0 1 0 0 0 0 0 0 0 0 0 0 |          |
|                 {2} | 0 0 0 0 1 0 0 0 0 0 0 0 0 0 |          |
|                 {2} | 0 0 0 0 0 1 0 0 0 0 0 0 0 0 |          |
|                 {2} | 0 0 0 0 0 0 1 0 0 0 0 0 0 0 |          |
|                 {2} | 0 0 0 0 0 0 0 1 0 0 0 0 0 0 |          |
|                 {2} | 0 0 0 0 0 0 0 0 1 0 0 0 0 0 |          |
|                 {2} | 0 0 0 0 0 0 0 0 0 1 0 0 0 0 |          |
|                 {2} | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 |          |
|                 {2} | 0 0 0 0 0 0 0 0 0 0 0 1 0 0 |          |
|                 {2} | 0 0 0 0 0 0 0 0 0 0 0 0 1 0 |          |
|                 {2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 1 |          |
|                                                              |
|           4                       4                          |
|      3 : S  <------------------- S  : 3                      |
|                {3} | 1 0 0 0 |                               |
|                {3} | 0 1 0 0 |                               |
|                {3} | 0 0 1 0 |                               |
|                {3} | 0 0 0 1 |                               |
|                                                              |
|o15 : ComplexMap                                              |
+--------------------------------------------------------------+
|i16 : assert isWellDefined g                                  |
+--------------------------------------------------------------+
|i17 : assert(g * f == 1)                                      |
+--------------------------------------------------------------+
|i18 : assert(f * g == 1)                                      |
+--------------------------------------------------------------+

We illustrate this isomorphism on complexes, none of whose terms are free
modules.

+-----------------------------------------------------------------------------+
|i19 : ses = (I,J) -> (                                                       |
|          complex{                                                           |
|              map(S^1/(I+J), S^1/I ++ S^1/J, {{1,1}}),                       |
|              map(S^1/I ++ S^1/J, S^1/(intersect(I,J)), {{1},{-1}})          |
|              }                                                              |
|          )                                                                  |
|                                                                             |
|o19 = ses                                                                    |
|                                                                             |
|o19 : FunctionClosure                                                        |
+-----------------------------------------------------------------------------+
|i20 : C = ses(ideal(x_0,x_1), ideal(x_1,x_2))                                |
|                                                                             |
|o20 = cokernel | x_0 x_1 x_1 x_2 | <-- cokernel | x_0 x_1 0   0   | <--      |
|                                                | 0   0   x_1 x_2 |          |
|      0                                                                      |
|                                       1                                     |
|                                                                             |
|o20 : Complex                                                                |
|-----------------------------------------------------------------------------|
|cokernel | x_1 x_0x_2 |                                                      |
|                                                                             |
|2                                                                            |
+-----------------------------------------------------------------------------+
|i21 : D = ses(ideal(x_3,x_4,x_5), ideal(x_6,x_7,x_8))                        |
|                                                                             |
|o21 = cokernel | x_3 x_4 x_5 x_6 x_7 x_8 | <-- cokernel | x_3 x_4 x_5 0   0  |
|                                                        | 0   0   0   x_6 x_7|
|      0                                                                      |
|                                               1                             |
|                                                                             |
|o21 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0   | <-- cokernel | x_5x_8 x_4x_8 x_3x_8 x_5x_7 x_4x_7 x_3x_7 x_5x_6 x_4x_6 |
|x_8 |                                                                        |
|          2                                                                  |
|-----------------------------------------------------------------------------|
|x_3x_6 |                                                                     |
+-----------------------------------------------------------------------------+
|i22 : E = ses(ideal(x_1^2, x_1*x_2), ideal(x_1*x_3,x_9^2))                   |
|                                                                             |
|o22 = cokernel | x_1^2 x_1x_2 x_1x_3 x_9^2 | <-- cokernel | x_1^2 x_1x_2     |
|                                                          | 0     0          |
|      0                                                                      |
|                                                 1                           |
|                                                                             |
|o22 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0      0     | <-- cokernel | x_1x_2x_3 x_1^2x_3 x_1x_2x_9^2 x_1^2x_9^2 |    |
|x_1x_3 x_9^2 |                                                               |
|                   2                                                         |
+-----------------------------------------------------------------------------+
|i23 : h = tensorAssociativity(C, D, E);                                      |
+-----------------------------------------------------------------------------+
|i24 : assert isWellDefined h                                                 |
+-----------------------------------------------------------------------------+
|i25 : assert(ker h == 0)                                                     |
+-----------------------------------------------------------------------------+
|i26 : assert(coker h == 0)                                                   |
+-----------------------------------------------------------------------------+
|i27 : k = h^-1;                                                              |
+-----------------------------------------------------------------------------+
|i28 : assert(h*k == 1)                                                       |
+-----------------------------------------------------------------------------+
|i29 : assert(k*h == 1)                                                       |
+-----------------------------------------------------------------------------+
|i30 : h_2                                                                    |
|                                                                             |
|o30 = | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                                      |
|      | 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 |                                      |
|      | 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |                                      |
|      | 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 |                                      |
|      | 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 |                                      |
|      | 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 |                                      |
|      | 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 |                                      |
|      | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 |                                      |
|      | 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 |                                      |
|      | 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 |                                      |
|      | 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 |                                      |
|      | 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 |                                      |
|      | 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 |                                      |
|      | 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 |                                      |
|      | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 |                                      |
|                                                                             |
|o30 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i31 : assert(source h_2 != target h_2)                                       |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Tor -- information about functorial
    properties
  * tensorCommutativity(Complex,Complex)
    -- make the canonical
    isomorphism arising from commutativity
  * tensorAssociativity(Module,Module,Module) (Macaulay2Doc)
    -- associativity isomorphisms for tensor
    products

Ways to use this method:
========================

  * tensorAssociativity(Complex,Complex,Complex)
    -- make the canonical
    isomorphism arising from associativity

tensorCommutativity(Complex,Complex) -- make the canonical isomorphism arising from commutativity
*************************************************************************************************

Synopsis
========

  * Function: tensorCommutativity,
  * Usage:
        tensorCommutativity(C, D)
  * Inputs:
      * C, a complex,
      * D, a complex, both over the same ring $R$
  * Outputs:
      * a map of complexes, that is an isomorphism from $C
        \otimes_R D$ to $D \otimes_R C$

Description
===========

The commutativity of tensor products of modules induces the commutativity of
tensor products of chain complexes. This method implements this isomorphism for
chain complexes.

Using two term complexes of small rank, we see that this isomorphism need not
be the identity map.

+------------------------------------------+
|i1 : S = ZZ/101[x_0..x_8];                |
+------------------------------------------+
|i2 : C = complex{genericMatrix(S,x_0,2,1)}|
|                                          |
|      2      1                            |
|o2 = S  <-- S                             |
|                                          |
|     0      1                             |
|                                          |
|o2 : Complex                              |
+------------------------------------------+
|i3 : D = complex{genericMatrix(S,x_2,1,2)}|
|                                          |
|      1      2                            |
|o3 = S  <-- S                             |
|                                          |
|     0      1                             |
|                                          |
|o3 : Complex                              |
+------------------------------------------+
|i4 : F = C ** D                           |
|                                          |
|      2      5      2                     |
|o4 = S  <-- S  <-- S                      |
|                                          |
|     0      1      2                      |
|                                          |
|o4 : Complex                              |
+------------------------------------------+
|i5 : G = D ** C                           |
|                                          |
|      2      5      2                     |
|o5 = S  <-- S  <-- S                      |
|                                          |
|     0      1      2                      |
|                                          |
|o5 : Complex                              |
+------------------------------------------+
|i6 : f = tensorCommutativity(C,D)         |
|                                          |
|          2               2               |
|o6 = 0 : S  <----------- S  : 0           |
|               | 1 0 |                    |
|               | 0 1 |                    |
|                                          |
|          5                         5     |
|     1 : S  <--------------------- S  : 1 |
|               {1} | 0 0 0 0 1 |          |
|               {1} | 1 0 0 0 0 |          |
|               {1} | 0 0 1 0 0 |          |
|               {1} | 0 1 0 0 0 |          |
|               {1} | 0 0 0 1 0 |          |
|                                          |
|          2                     2         |
|     2 : S  <----------------- S  : 2     |
|               {2} | -1 0  |              |
|               {2} | 0  -1 |              |
|                                          |
|o6 : ComplexMap                           |
+------------------------------------------+
|i7 : assert isWellDefined f               |
+------------------------------------------+
|i8 : assert isComplexMorphism f           |
+------------------------------------------+
|i9 : assert(source f === F)               |
+------------------------------------------+
|i10 : assert(target f === G)              |
+------------------------------------------+
|i11 : assert(f_1 != id_(source f_1))      |
+------------------------------------------+
|i12 : assert(prune ker f == 0)            |
+------------------------------------------+
|i13 : assert(prune coker f == 0)          |
+------------------------------------------+
|i14 : g = f^-1                            |
|                                          |
|           2               2              |
|o14 = 0 : S  <----------- S  : 0          |
|                | 1 0 |                   |
|                | 0 1 |                   |
|                                          |
|           5                         5    |
|      1 : S  <--------------------- S  : 1|
|                {1} | 0 1 0 0 0 |         |
|                {1} | 0 0 0 1 0 |         |
|                {1} | 0 0 1 0 0 |         |
|                {1} | 0 0 0 0 1 |         |
|                {1} | 1 0 0 0 0 |         |
|                                          |
|           2                     2        |
|      2 : S  <----------------- S  : 2    |
|                {2} | -1 0  |             |
|                {2} | 0  -1 |             |
|                                          |
|o14 : ComplexMap                          |
+------------------------------------------+
|i15 : assert isWellDefined g              |
+------------------------------------------+
|i16 : assert(g * f == 1)                  |
+------------------------------------------+
|i17 : assert(f * g == 1)                  |
+------------------------------------------+

We illustrate this isomorphism on complexes, none of whose terms are free
modules.

+-----------------------------------------------------------------------------+
|i18 : ses = (I,J) -> (                                                       |
|          complex{                                                           |
|              map(S^1/(I+J), S^1/I ++ S^1/J, {{1,1}}),                       |
|              map(S^1/I ++ S^1/J, S^1/(intersect(I,J)), {{1},{-1}})          |
|              }                                                              |
|          )                                                                  |
|                                                                             |
|o18 = ses                                                                    |
|                                                                             |
|o18 : FunctionClosure                                                        |
+-----------------------------------------------------------------------------+
|i19 : C = ses(ideal(x_0,x_1), ideal(x_1,x_2))                                |
|                                                                             |
|o19 = cokernel | x_0 x_1 x_1 x_2 | <-- cokernel | x_0 x_1 0   0   | <--      |
|                                                | 0   0   x_1 x_2 |          |
|      0                                                                      |
|                                       1                                     |
|                                                                             |
|o19 : Complex                                                                |
|-----------------------------------------------------------------------------|
|cokernel | x_1 x_0x_2 |                                                      |
|                                                                             |
|2                                                                            |
+-----------------------------------------------------------------------------+
|i20 : D = ses(ideal(x_3,x_4,x_5), ideal(x_6,x_7,x_8))                        |
|                                                                             |
|o20 = cokernel | x_3 x_4 x_5 x_6 x_7 x_8 | <-- cokernel | x_3 x_4 x_5 0   0  |
|                                                        | 0   0   0   x_6 x_7|
|      0                                                                      |
|                                               1                             |
|                                                                             |
|o20 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0   | <-- cokernel | x_5x_8 x_4x_8 x_3x_8 x_5x_7 x_4x_7 x_3x_7 x_5x_6 x_4x_6 |
|x_8 |                                                                        |
|          2                                                                  |
|-----------------------------------------------------------------------------|
|x_3x_6 |                                                                     |
+-----------------------------------------------------------------------------+
|i21 : h = tensorCommutativity(C, D);                                         |
+-----------------------------------------------------------------------------+
|i22 : assert isWellDefined h                                                 |
+-----------------------------------------------------------------------------+
|i23 : assert isComplexMorphism h                                             |
+-----------------------------------------------------------------------------+
|i24 : assert(ker h == 0)                                                     |
+-----------------------------------------------------------------------------+
|i25 : assert(coker h == 0)                                                   |
+-----------------------------------------------------------------------------+
|i26 : k = h^-1;                                                              |
+-----------------------------------------------------------------------------+
|i27 : assert(h*k == 1)                                                       |
+-----------------------------------------------------------------------------+
|i28 : assert(k*h == 1)                                                       |
+-----------------------------------------------------------------------------+
|i29 : h_2                                                                    |
|                                                                             |
|o29 = | 0 0  0  0  0  1 |                                                    |
|      | 0 -1 0  0  0  0 |                                                    |
|      | 0 0  0  -1 0  0 |                                                    |
|      | 0 0  -1 0  0  0 |                                                    |
|      | 0 0  0  0  -1 0 |                                                    |
|      | 1 0  0  0  0  0 |                                                    |
|                                                                             |
|o29 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i30 : assert(source h_2 != target h_2)                                       |
+-----------------------------------------------------------------------------+

Interchanging the arguments gives the inverse map.

+-----------------------------------------------------------------------------+
|i31 : h1 = tensorCommutativity(D, C)                                         |
|                                                                             |
|o31 = 0 : cokernel | x_3 x_4 x_5 x_6 x_7 x_8 x_0                             |
|                                                                             |
|                                                                             |
|      1 : cokernel | x_3 x_4 x_5 0   0   0   x_0                             |
|                   | 0   0   0   x_6 x_7 x_8 0                               |
|                   | 0   0   0   0   0   0   0                               |
|                   | 0   0   0   0   0   0   0                               |
|                                                                             |
|                                                                             |
|      2 : cokernel | x_5x_8 x_4x_8 x_3x_8 x_5x_7                             |
|                   | 0      0      0      0                                  |
|                   | 0      0      0      0                                  |
|                   | 0      0      0      0                                  |
|                   | 0      0      0      0                                  |
|                   | 0      0      0      0                                  |
|                                                                             |
|                                                                             |
|      3 : cokernel | x_5x_8 x_4x_8 x_3x_8 x_5x_7                             |
|                   | 0      0      0      0                                  |
|                   | 0      0      0      0                                  |
|                   | 0      0      0      0                                  |
|                                                                             |
|                                                                             |
|      4 : cokernel | x_5x_8 x_4x_8 x_3x_8 x_5x_7                             |
|                                                                             |
|                                                                             |
|o31 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|x_1 x_1 x_2 | <--------- cokernel | x_0 x_1 x_1 x_2 x_3 x_4 x_5 x_6 x_7 x_8  |
|                 | 1 |                                                       |
|                                                                             |
|x_1 x_1 x_2 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0    |
|0   0   0   x_0 x_1 x_1 x_2 0   0   0   0   0   0   0   0   0   0   0   0    |
|0   0   0   0   0   0   0   x_3 x_4 x_5 x_6 x_7 x_8 0   0   0   0   0   0    |
|0   0   0   0   0   0   0   0   0   0   0   0   0   x_3 x_4 x_5 x_6 x_7 x_8  |
|                                                                             |
|                                                                             |
|x_4x_7 x_3x_7 x_5x_6 x_4x_6 x_3x_6 x_0 x_1 x_1 x_2 0   0   0   0   0   0   0 |
|0      0      0      0      0      0   0   0   0   x_3 x_4 x_5 0   0   0   0 |
|0      0      0      0      0      0   0   0   0   0   0   0   x_6 x_7 x_8 0 |
|0      0      0      0      0      0   0   0   0   0   0   0   0   0   0   x |
|0      0      0      0      0      0   0   0   0   0   0   0   0   0   0   0 |
|0      0      0      0      0      0   0   0   0   0   0   0   0   0   0   0 |
|                                                                             |
|                                                                             |
|x_4x_7 x_3x_7 x_5x_6 x_4x_6 x_3x_6 0      0      0      0      0      0      |
|0      0      0      0      0      x_5x_8 x_4x_8 x_3x_8 x_5x_7 x_4x_7 x_3x_7 |
|0      0      0      0      0      0      0      0      0      0      0      |
|0      0      0      0      0      0      0      0      0      0      0      |
|                                                                             |
|                                                                             |
|x_4x_7 x_3x_7 x_5x_6 x_4x_6 x_3x_6 x_1 x_0x_2 | <--------- cokernel | x_1 x_ |
|                                                   | 1 |                     |
|-----------------------------------------------------------------------------|
|| : 0                                                                        |
|                                                                             |
|                                                                             |
|0   0   0   0   | <--------------- cokernel | x_0 x_1 0   0   x_3 x_4 x_5 x_6|
|0   0   0   0   |    | 0 0 1 0 |            | 0   0   x_1 x_2 0   0   0   0  |
|x_0 x_1 0   0   |    | 0 0 0 1 |            | 0   0   0   0   0   0   0   0  |
|0   0   x_1 x_2 |    | 1 0 0 0 |            | 0   0   0   0   0   0   0   0  |
|                     | 0 1 0 0 |                                             |
|                                                                             |
|   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 |
|   0   0   0   0   0   x_0 x_1 0   0   0   0   0   0   0   0   0   0   0   0 |
|   0   0   0   0   0   0   0   0   0   x_0 x_1 0   0   0   0   0   0   0   0 |
|_3 x_4 x_5 0   0   0   0   0   x_1 x_2 0   0   0   0   0   0   0   0   0   0 |
|   0   0   x_6 x_7 x_8 0   0   0   0   0   0   x_1 x_2 0   0   0   0   0   0 |
|   0   0   0   0   0   0   0   0   0   0   0   0   0   x_3 x_4 x_5 x_6 x_7 x_|
|                                                                             |
|                                                                             |
| 0      0      0      x_0 x_1 0   0   0   0   0   0   0   0   0   0      0   |
| x_5x_6 x_4x_6 x_3x_6 0   0   x_1 x_2 0   0   0   0   0   0   0   0      0   |
| 0      0      0      0   0   0   0   x_3 x_4 x_5 0   0   0   x_1 x_0x_2 0   |
| 0      0      0      0   0   0   0   0   0   0   x_6 x_7 x_8 0   0      x_1 |
|                                                                             |
|                                                                             |
|0x_2 x_5x_8 x_4x_8 x_3x_8 x_5x_7 x_4x_7 x_3x_7 x_5x_6 x_4x_6 x_3x_6 | : 4    |
|-----------------------------------------------------------------------------|
| x_7 x_8 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   |
| 0   0   x_3 x_4 x_5 x_6 x_7 x_8 0   0   0   0   0   0   0   0   0   0   0   |
| 0   0   0   0   0   0   0   0   x_0 x_1 x_1 x_2 0   0   0   0   x_3 x_4 x_5 |
| 0   0   0   0   0   0   0   0   0   0   0   0   x_0 x_1 x_1 x_2 0   0   0   |
|                                                                             |
|                                                                             |
|  0   0      | <----------------------- cokernel | x_1 x_0x_2 x_3 x_4 x_5 x_6|
|  0   0      |    | 0 0  0  0  0  1 |            | 0   0      0   0   0   0  |
|  0   0      |    | 0 -1 0  0  0  0 |            | 0   0      0   0   0   0  |
|  0   0      |    | 0 0  0  -1 0  0 |            | 0   0      0   0   0   0  |
|  0   0      |    | 0 0  -1 0  0  0 |            | 0   0      0   0   0   0  |
|8 x_1 x_0x_2 |    | 0 0  0  0  -1 0 |            | 0   0      0   0   0   0  |
|                  | 1 0  0  0  0  0 |                                        |
|                                                                             |
|0      | <--------------- cokernel | x_1 x_0x_2 0   0      x_3 x_4 x_5 0   0 |
|0      |    | 0 0 1 0 |            | 0   0      x_1 x_0x_2 0   0   0   x_6 x_|
|0      |    | 0 0 0 1 |            | 0   0      0   0      0   0   0   0   0 |
|x_0x_2 |    | 1 0 0 0 |            | 0   0      0   0      0   0   0   0   0 |
|            | 0 1 0 0 |                                                      |
|-----------------------------------------------------------------------------|
|0   0   0   | : 1                                                            |
|0   0   0   |                                                                |
|0   0   0   |                                                                |
|x_6 x_7 x_8 |                                                                |
|                                                                             |
|                                                                             |
| x_7 x_8 0   0   0   0   0   0   0   0   0   0   0   0                       |
| 0   0   x_0 x_1 0   0   0   0   0   0   x_3 x_4 x_5 0                       |
| 0   0   0   0   x_1 x_2 0   0   0   0   0   0   0   0                       |
| 0   0   0   0   0   0   x_0 x_1 0   0   0   0   0   x_6                     |
| 0   0   0   0   0   0   0   0   x_1 x_2 0   0   0   0                       |
| 0   0   0   0   0   0   0   0   0   0   0   0   0   0                       |
|                                                                             |
|                                                                             |
|  0   0   0   0   0   0      0      0      0      0                          |
|7 x_8 0   0   0   0   0      0      0      0      0                          |
|  0   x_0 x_1 0   0   x_5x_8 x_4x_8 x_3x_8 x_5x_7 x_4x_7                     |
|  0   0   0   x_1 x_2 0      0      0      0      0                          |
|-----------------------------------------------------------------------------|
|0   0   0   0   0   0   0                                                    |
|0   0   0   0   0   0   0                                                    |
|0   0   x_3 x_4 x_5 0   0                                                    |
|x_7 x_8 0   0   0   0   0                                                    |
|0   0   0   0   0   x_6 x_7                                                  |
|0   0   0   0   0   0   0                                                    |
|                                                                             |
|                                                                             |
|0      0      0      0                                                       |
|0      0      0      0                                                       |
|x_3x_7 x_5x_6 x_4x_6 x_3x_6                                                  |
|0      0      0      0                                                       |
|-----------------------------------------------------------------------------|
|0   0   0   0   0   0      0      0      0      0      0      0      0       |
|0   0   0   0   0   0      0      0      0      0      0      0      0       |
|0   0   0   0   0   0      0      0      0      0      0      0      0       |
|0   0   0   0   0   0      0      0      0      0      0      0      0       |
|x_8 0   0   0   0   0      0      0      0      0      0      0      0       |
|0   x_0 x_1 x_1 x_2 x_5x_8 x_4x_8 x_3x_8 x_5x_7 x_4x_7 x_3x_7 x_5x_6 x_4x_6  |
|                                                                             |
|                                                                             |
|0      0      0      0      0      0      0      0      0      | : 3         |
|0      0      0      0      0      0      0      0      0      |             |
|0      0      0      0      0      0      0      0      0      |             |
|x_5x_8 x_4x_8 x_3x_8 x_5x_7 x_4x_7 x_3x_7 x_5x_6 x_4x_6 x_3x_6 |             |
|-----------------------------------------------------------------------------|
|0      | : 2                                                                 |
|0      |                                                                     |
|0      |                                                                     |
|0      |                                                                     |
|0      |                                                                     |
|x_3x_6 |                                                                     |
+-----------------------------------------------------------------------------+
|i32 : assert isComplexMorphism h1                                            |
+-----------------------------------------------------------------------------+
|i33 : assert(h1*h == id_(C**D))                                              |
+-----------------------------------------------------------------------------+
|i34 : assert(h*h1 == id_(D**C))                                              |
+-----------------------------------------------------------------------------+

Interchanging the factors in a tensor product of two complex maps can be
accomplished as follows.

+-----------------------------------------------------------------------------+
|i35 : C = freeResolution ideal(x_0^2, x_1^2)                                 |
|                                                                             |
|       1      2      1                                                       |
|o35 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o35 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i36 : D = freeResolution ideal(x_0, x_1)                                     |
|                                                                             |
|       1      2      1                                                       |
|o36 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o36 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i37 : f = extend(D, C, map(D_0, C_0, 1))                                     |
|                                                                             |
|           1             1                                                   |
|o37 = 0 : S  <--------- S  : 0                                               |
|                | 1 |                                                        |
|                                                                             |
|           2                       2                                         |
|      1 : S  <------------------- S  : 1                                     |
|                {1} | x_0 0   |                                              |
|                {1} | 0   x_1 |                                              |
|                                                                             |
|           1                      1                                          |
|      2 : S  <------------------ S  : 2                                      |
|                {2} | x_0x_1 |                                               |
|                                                                             |
|o37 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i38 : E = freeResolution ideal(x_2^3, x_3^3, x_4^3)                          |
|                                                                             |
|       1      3      3      1                                                |
|o38 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o38 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i39 : F = freeResolution ideal(x_2, x_3, x_4)                                |
|                                                                             |
|       1      3      3      1                                                |
|o39 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o39 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i40 : g = extend(F, E, map(F_0, E_0, 1))                                     |
|                                                                             |
|           1             1                                                   |
|o40 = 0 : S  <--------- S  : 0                                               |
|                | 1 |                                                        |
|                                                                             |
|           3                                 3                               |
|      1 : S  <----------------------------- S  : 1                           |
|                {1} | x_2^2 0     0     |                                    |
|                {1} | 0     x_3^2 0     |                                    |
|                {1} | 0     0     x_4^2 |                                    |
|                                                                             |
|           3                                                3                |
|      2 : S  <-------------------------------------------- S  : 2            |
|                {2} | x_2^2x_3^2 0          0          |                     |
|                {2} | 0          x_2^2x_4^2 0          |                     |
|                {2} | 0          0          x_3^2x_4^2 |                     |
|                                                                             |
|           1                               1                                 |
|      3 : S  <--------------------------- S  : 3                             |
|                {3} | x_2^2x_3^2x_4^2 |                                      |
|                                                                             |
|o40 : ComplexMap                                                             |
+-----------------------------------------------------------------------------+
|i41 : assert(tensorCommutativity(D,F) * (f**g) == (g**f) *                   |
|-----------------------------------------------------------------------------|
|tensorCommutativity(C,E))                                                    |
+-----------------------------------------------------------------------------+
|i42 : assert isComplexMorphism tensorCommutativity(D,F)                      |
+-----------------------------------------------------------------------------+
|i43 : assert isComplexMorphism tensorCommutativity(C,E)                      |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Tor -- information about functorial
    properties
  * tensorCommutativity(Module,Module)
    -- make the canonical isomorphism
    arising from commutativity
  * tensorAssociativity(Complex,Complex,Complex)
    -- make the canonical
    isomorphism arising from associativity
  * isComplexMorphism(ComplexMap), --
    whether a complex map is a morphism of complexes

Ways to use this method:
========================

  * tensorCommutativity(Complex,Complex)
    -- make the canonical
    isomorphism arising from commutativity

tensorCommutativity(Module,Module) -- make the canonical isomorphism arising from commutativity
***********************************************************************************************

Synopsis
========

  * Function: tensorCommutativity,
  * Usage:
        tensorCommutativity(M, N)
  * Inputs:
      * M, a module (Macaulay2Doc),
      * N, a module (Macaulay2Doc), both over the same ring $R$
  * Outputs:
      * a matrix (Macaulay2Doc), that is an isomorphism from $M
        \otimes_R N$ to $N \otimes_R M$.

Description
===========

Given $R$-modules $M$ and $N$, there exists a canonical isomorphism $f \colon M
\otimes_R N \to N \otimes_R M$ interchanging the factors. This method
implements this isomorphism.

Even for free modules, this map is not simply given by the identity matrix.

+----------------------------------+
|i1 : R = ZZ/101[x,y];             |
+----------------------------------+
|i2 : M = R^2                      |
|                                  |
|      2                           |
|o2 = R                            |
|                                  |
|o2 : R-module, free               |
+----------------------------------+
|i3 : N = R^3                      |
|                                  |
|      3                           |
|o3 = R                            |
|                                  |
|o3 : R-module, free               |
+----------------------------------+
|i4 : f = tensorCommutativity(M, N)|
|                                  |
|o4 = | 1 0 0 0 0 0 |              |
|     | 0 0 0 1 0 0 |              |
|     | 0 1 0 0 0 0 |              |
|     | 0 0 0 0 1 0 |              |
|     | 0 0 1 0 0 0 |              |
|     | 0 0 0 0 0 1 |              |
|                                  |
|             6       6            |
|o4 : Matrix R  <--- R             |
+----------------------------------+
|i5 : assert isWellDefined f       |
+----------------------------------+
|i6 : assert isIsomorphism f       |
+----------------------------------+

By giving the generators of $M$ and $N$ sufficiently different degrees, we see
that the canonical generators for the two tensor products come in different
orders. The isomorphism is given by the corresponding permutation matrix.

+------------------------------------------------------------------+
|i7 : M = R^{1,2}                                                  |
|                                                                  |
|      2                                                           |
|o7 = R                                                            |
|                                                                  |
|o7 : R-module, free, degrees {-1, -2}                             |
+------------------------------------------------------------------+
|i8 : N = R^{100,200,300}                                          |
|                                                                  |
|      3                                                           |
|o8 = R                                                            |
|                                                                  |
|o8 : R-module, free, degrees {-100, -200, -300}                   |
+------------------------------------------------------------------+
|i9 : M ** N                                                       |
|                                                                  |
|      6                                                           |
|o9 = R                                                            |
|                                                                  |
|o9 : R-module, free, degrees {-101, -201, -301, -102, -202, -302} |
+------------------------------------------------------------------+
|i10 : N ** M                                                      |
|                                                                  |
|       6                                                          |
|o10 = R                                                           |
|                                                                  |
|o10 : R-module, free, degrees {-101, -102, -201, -202, -301, -302}|
+------------------------------------------------------------------+
|i11 : tensorCommutativity(M, N)                                   |
|                                                                  |
|o11 = {-101} | 1 0 0 0 0 0 |                                      |
|      {-102} | 0 0 0 1 0 0 |                                      |
|      {-201} | 0 1 0 0 0 0 |                                      |
|      {-202} | 0 0 0 0 1 0 |                                      |
|      {-301} | 0 0 1 0 0 0 |                                      |
|      {-302} | 0 0 0 0 0 1 |                                      |
|                                                                  |
|              6       6                                           |
|o11 : Matrix R  <--- R                                            |
+------------------------------------------------------------------+

For completeness, we include an example when neither module is free.

+-------------------------------------------------------------------------+
|i12 : g = tensorCommutativity(coker vars R ++ coker vars R, image vars R)|
|                                                                         |
|o12 = {1} | 1 0 0 0 |                                                    |
|      {1} | 0 0 1 0 |                                                    |
|      {1} | 0 1 0 0 |                                                    |
|      {1} | 0 0 0 1 |                                                    |
|                                                                         |
|o12 : Matrix                                                             |
+-------------------------------------------------------------------------+
|i13 : source g                                                           |
|                                                                         |
|o13 = cokernel {1} | -y 0  x y 0 0 0 0 0 0 |                             |
|               {1} | x  0  0 0 0 0 x y 0 0 |                             |
|               {1} | 0  -y 0 0 x y 0 0 0 0 |                             |
|               {1} | 0  x  0 0 0 0 0 0 x y |                             |
|                                                                         |
|                             4                                           |
|o13 : R-module, quotient of R                                            |
+-------------------------------------------------------------------------+
|i14 : target g                                                           |
|                                                                         |
|o14 = cokernel {1} | x y 0 0 0 0 0 0 -y 0  |                             |
|               {1} | 0 0 x y 0 0 0 0 0  -y |                             |
|               {1} | 0 0 0 0 x y 0 0 x  0  |                             |
|               {1} | 0 0 0 0 0 0 x y 0  x  |                             |
|                                                                         |
|                             4                                           |
|o14 : R-module, quotient of R                                            |
+-------------------------------------------------------------------------+
|i15 : assert isWellDefined g                                             |
+-------------------------------------------------------------------------+
|i16 : assert isIsomorphism g                                             |
+-------------------------------------------------------------------------+

See also
========

  * Working with Tor -- information about functorial
    properties
  * tensorCommutativity(Complex,Complex)
    -- make the canonical
    isomorphism arising from commutativity
  * tensorAssociativity(Module,Module,Module) (Macaulay2Doc)
    -- associativity isomorphisms for tensor
    products
  * isIsomorphism(Matrix) (Macaulay2Doc) -- whether a map
    is an isomorphism

Ways to use this method:
========================

  * tensorCommutativity(Module,Module)
    -- make the canonical isomorphism
    arising from commutativity

Tor_ZZ(Matrix,Module) -- make the induced map on Tor modules
************************************************************

Synopsis
========

  * Scripted functor: Tor (Macaulay2Doc),
  * Usage:
        g = Tor_i(f, M)
        h = Tor_i(M, f)
  * Inputs:
      * i, an integer (Macaulay2Doc),
      * f, a matrix (Macaulay2Doc), defining a homomorphism from
        the $R$-module $L$ to the $R$-module $N$
      * M, a module (Macaulay2Doc), over the ring $R$
  * Outputs:
      * g, a matrix (Macaulay2Doc), defining the induced
        homomorphism from $\operatorname{Tor}_i^R(L, M)$ to
        $\operatorname{Tor}_i^R(N, M)$, or the matrix $h$ defining the induced
        homomorphism from $\operatorname{Tor}_i^R(M, L)$ to
        $\operatorname{Tor}_i^R(M, N)$

Description
===========

The $\operatorname{Tor}$ functors are derived functors of the tensor product
functor. Given a homomorphism $f \colon L \to N$ of $R$-modules and an
$R$-module $M$, this method returns the induced homomorphism $g \colon
\operatorname{Tor}_i^R(L, M) \to \operatorname{Tor}_i^R(N, M)$.

+------------------------------------------------------+
|i1 : R = ZZ/101[a..d];                                |
+------------------------------------------------------+
|i2 : L = R^1/ideal(a^2, b^2, c^2, a*c, b*d)           |
|                                                      |
|o2 = cokernel | a2 b2 c2 ac bd |                      |
|                                                      |
|                            1                         |
|o2 : R-module, quotient of R                          |
+------------------------------------------------------+
|i3 : N = R^1/ideal(a^2, b^2, c^2, a*c, b*d, a*b)      |
|                                                      |
|o3 = cokernel | a2 b2 c2 ac bd ab |                   |
|                                                      |
|                            1                         |
|o3 : R-module, quotient of R                          |
+------------------------------------------------------+
|i4 : f = map(N,L,1)                                   |
|                                                      |
|o4 = | 1 |                                            |
|                                                      |
|o4 : Matrix                                           |
+------------------------------------------------------+
|i5 : M = coker vars R                                 |
|                                                      |
|o5 = cokernel | a b c d |                             |
|                                                      |
|                            1                         |
|o5 : R-module, quotient of R                          |
+------------------------------------------------------+
|i6 : betti freeResolution L                           |
|                                                      |
|            0 1 2 3 4                                 |
|o6 = total: 1 5 9 7 2                                 |
|         0: 1 . . . .                                 |
|         1: . 5 3 . .                                 |
|         2: . . 6 7 2                                 |
|                                                      |
|o6 : BettiTally                                       |
+------------------------------------------------------+
|i7 : betti freeResolution N                           |
|                                                      |
|            0 1 2 3 4                                 |
|o7 = total: 1 6 9 5 1                                 |
|         0: 1 . . . .                                 |
|         1: . 6 7 2 .                                 |
|         2: . . 2 3 1                                 |
|                                                      |
|o7 : BettiTally                                       |
+------------------------------------------------------+
|i8 : g1 = Tor_1(f, M)                                 |
|                                                      |
|o8 = {2} | 1 0 0 0 0 |                                |
|     {2} | 0 0 0 0 0 |                                |
|     {2} | 0 1 0 0 0 |                                |
|     {2} | 0 0 1 0 0 |                                |
|     {2} | 0 0 0 1 0 |                                |
|     {2} | 0 0 0 0 1 |                                |
|                                                      |
|o8 : Matrix                                           |
+------------------------------------------------------+
|i9 : g2 = Tor_2(f, M)                                 |
|                                                      |
|o9 = {3} | 0 0 0 0 0 0 0 0 0 |                        |
|     {3} | 0 0 0 0 0 0 0 0 0 |                        |
|     {3} | 1 0 0 0 0 0 0 0 0 |                        |
|     {3} | 0 0 0 0 0 0 0 0 0 |                        |
|     {3} | 0 1 0 0 0 0 0 0 0 |                        |
|     {3} | 0 0 0 0 0 0 0 0 0 |                        |
|     {3} | 0 0 1 0 0 0 0 0 0 |                        |
|     {4} | 0 0 0 0 0 1 0 0 0 |                        |
|     {4} | 0 0 0 0 0 0 0 0 1 |                        |
|                                                      |
|o9 : Matrix                                           |
+------------------------------------------------------+
|i10 : g3 = Tor_3(f, M)                                |
|                                                      |
|o10 = {4} | 0 0 0 0 0 0 0 |                           |
|      {4} | 0 0 0 0 0 0 0 |                           |
|      {5} | 0 1 0 0 0 0 0 |                           |
|      {5} | 0 0 0 0 0 1 0 |                           |
|      {5} | 0 0 0 0 0 0 1 |                           |
|                                                      |
|o10 : Matrix                                          |
+------------------------------------------------------+
|i11 : g4 = Tor_4(f, M)                                |
|                                                      |
|o11 = {6} | 0 1 |                                     |
|                                                      |
|o11 : Matrix                                          |
+------------------------------------------------------+
|i12 : assert(source g2 === Tor_2(L, M))               |
+------------------------------------------------------+
|i13 : assert(target g2 === Tor_2(N, M))               |
+------------------------------------------------------+
|i14 : prune ker g3                                    |
|                                                      |
|o14 = cokernel {5} | d c b a 0 0 0 0 0 0 0 0 0 0 0 0 ||
|               {5} | 0 0 0 0 d c b a 0 0 0 0 0 0 0 0 ||
|               {5} | 0 0 0 0 0 0 0 0 d c b a 0 0 0 0 ||
|               {5} | 0 0 0 0 0 0 0 0 0 0 0 0 d c b a ||
|                                                      |
|                             4                        |
|o14 : R-module, quotient of R                         |
+------------------------------------------------------+
|i15 : prune coker g3                                  |
|                                                      |
|o15 = cokernel {4} | d c b a 0 0 0 0 |                |
|               {4} | 0 0 0 0 d c b a |                |
|                                                      |
|                             2                        |
|o15 : R-module, quotient of R                         |
+------------------------------------------------------+

Although the $\operatorname{Tor}$ functors are symmetric, the actual matrices
depend on the order of the arguments.

+-----------------------------------------------------------------------------+
|i16 : M = R^1/ideal(a^2,b^2,c^3,b*d)                                         |
|                                                                             |
|o16 = cokernel | a2 b2 c3 bd |                                               |
|                                                                             |
|                             1                                               |
|o16 : R-module, quotient of R                                                |
+-----------------------------------------------------------------------------+
|i17 : h1 = Tor_1(M, f)                                                       |
|                                                                             |
|o17 = {2} | 1 0 0 0 |                                                        |
|      {2} | 0 1 0 0 |                                                        |
|      {2} | 0 0 1 0 |                                                        |
|      {3} | 0 0 0 1 |                                                        |
|                                                                             |
|o17 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i18 : h1' = Tor_1(f, M)                                                      |
|                                                                             |
|o18 = {2} | 1 0 0 0 0 0 0 0 0 0 |                                            |
|      {2} | 0 1 0 0 0 0 0 0 0 0 |                                            |
|      {2} | 0 0 1 0 0 0 0 0 0 0 |                                            |
|      {3} | 0 0 0 0 0 0 0 0 0 0 |                                            |
|      {3} | 0 0 0 0 0 0 0 0 0 0 |                                            |
|      {3} | 0 0 0 0 0 0 0 0 0 0 |                                            |
|      {3} | 0 0 0 0 0 0 0 0 0 0 |                                            |
|      {3} | 0 0 0 1 0 0 0 0 0 0 |                                            |
|      {3} | 0 0 0 0 1 0 0 0 0 0 |                                            |
|      {3} | 0 0 0 0 0 0 0 0 0 0 |                                            |
|      {4} | 0 0 0 0 0 0 0 0 0 0 |                                            |
|      {4} | 0 0 0 0 0 0 0 0 0 0 |                                            |
|                                                                             |
|o18 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i19 : Tor_1(L, M)                                                            |
|                                                                             |
|o19 = subquotient ({2} | 1 0 0 0 0 0  0  0  0  0  |, {2} | -c 0  0  0 0   0  |
|                   {2} | 0 1 0 0 0 0  0  0  0  0  |  {2} | 0  0  -d 0 -ac -c2|
|                   {2} | 0 0 0 a 0 -c bd b2 0  0  |  {2} | a  -c 0  0 0   0  |
|                   {2} | 0 0 0 0 c a  0  0  bd b2 |  {2} | 0  a  0  0 0   0  |
|                   {2} | 0 0 1 0 0 0  0  0  0  0  |  {2} | 0  0  b  0 0   0  |
|                                                                             |
|                                5                                            |
|o19 : R-module, subquotient of R                                             |
|-----------------------------------------------------------------------------|
|0 0  0  bd b2 a2 c3 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  |)       |
|0 0  0  0  0  0  0  bd b2 a2 c3 0  0  0  0  0  0  0  0  0  0  0  0  |        |
|0 0  0  0  0  0  0  0  0  0  0  bd b2 a2 c3 0  0  0  0  0  0  0  0  |        |
|0 0  0  0  0  0  0  0  0  0  0  0  0  0  0  bd b2 a2 c3 0  0  0  0  |        |
|0 ac c2 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  bd b2 a2 c3 |        |
+-----------------------------------------------------------------------------+
|i20 : Tor_1(M, L)                                                            |
|                                                                             |
|o20 = cokernel {2} | 0  0 0 0 0 0 bd c2 ac b2 a2 0  0  0  0  0  0  0  0  0   |
|               {2} | -d 0 0 0 0 0 0  0  0  0  0  bd c2 ac b2 a2 0  0  0  0   |
|               {2} | b  0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  bd c2 ac b2  |
|               {3} | 0  0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0   |
|                                                                             |
|                             4                                               |
|o20 : R-module, quotient of R                                                |
|-----------------------------------------------------------------------------|
|0  0  0  0  0  0  |                                                          |
|0  0  0  0  0  0  |                                                          |
|a2 0  0  0  0  0  |                                                          |
|0  bd c2 ac b2 a2 |                                                          |
+-----------------------------------------------------------------------------+
|i21 : assert(source h1 == Tor_1(M, L))                                       |
+-----------------------------------------------------------------------------+
|i22 : assert(source h1' == Tor_1(L, M))                                      |
+-----------------------------------------------------------------------------+
|i23 : h2 = Tor_2(M, f)                                                       |
|                                                                             |
|o23 = {4} | 1 0 0 0 0 0 0 0 0 |                                              |
|      {4} | 0 1 0 0 0 0 0 0 0 |                                              |
|      {4} | 0 0 1 0 0 0 0 0 0 |                                              |
|      {5} | 0 0 0 0 0 0 0 0 0 |                                              |
|      {5} | 0 0 0 0 0 0 0 0 0 |                                              |
|      {5} | 0 0 0 0 0 0 0 0 0 |                                              |
|      {5} | 0 0 0 0 0 0 1 0 0 |                                              |
|      {5} | 0 0 0 0 0 0 0 1 0 |                                              |
|      {5} | 0 0 0 0 0 0 0 0 1 |                                              |
|                                                                             |
|o23 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i24 : h2' = Tor_2(f, M)                                                      |
|                                                                             |
|o24 = {4} | 0 1 0 0 0 0 0 0 0 0 0 -c 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {4} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {4} | 0 0 1 0 0 0 0 0 0 0 0 0  0 0 0 c 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {4} | 1 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {4} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 1 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {5} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {6} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {6} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {6} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {6} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {6} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {6} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {6} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {6} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|      {6} | 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |         |
|                                                                             |
|o24 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i25 : prune h2                                                               |
|                                                                             |
|o25 = {4} | 1 0 0 0 0 0 |                                                    |
|      {4} | 0 1 0 0 0 0 |                                                    |
|      {4} | 0 0 1 0 0 0 |                                                    |
|      {5} | 0 0 0 1 0 0 |                                                    |
|      {5} | 0 0 0 0 1 0 |                                                    |
|      {5} | 0 0 0 0 0 1 |                                                    |
|                                                                             |
|o25 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i26 : prune h2'                                                              |
|                                                                             |
|o26 = {4} | 0 1 0 0 0 0 |                                                    |
|      {4} | 0 0 1 0 0 0 |                                                    |
|      {4} | 1 0 0 0 0 0 |                                                    |
|      {5} | 0 0 0 1 0 0 |                                                    |
|      {5} | 0 0 0 0 1 0 |                                                    |
|      {5} | 0 0 0 0 0 1 |                                                    |
|                                                                             |
|o26 : Matrix                                                                 |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Tor -- information about functorial
    properties

Ways to use this method:
========================

  * Tor_ZZ(Matrix,Module) -- make the
    induced map on Tor modules
  * "Tor_ZZ(Module,Matrix)"

torSymmetry(ZZ,Module,Module) -- makes the canonical isomorphism realizing the symmetry of Tor
**********************************************************************************************

Synopsis
========

  * Function: torSymmetry,
  * Usage:
        torSymmetry(i, M, N)
  * Inputs:
      * i, an integer (Macaulay2Doc),
      * M, a module (Macaulay2Doc),
      * N, a module (Macaulay2Doc), over the same ring $R$ as $M$
  * Outputs:
      * a matrix (Macaulay2Doc), representing an $R$-module
        homomorphism from $\operatorname{Tor}_i^R(M, N)$ to
        $\operatorname{Tor}_i^R(N, M)$

Description
===========

See Tensor commutativity, gives
rise to an isomorphism from $\operatorname{Tor}_i^R(M, N)$ to
$\operatorname{Tor}_i^R(N, M)$. This method returns this isomorphism.

We compute the Betti numbers of the Veronese surface in two ways:
$\operatorname{Tor}(M, \ZZ/101)$ or via Koszul cohomology
$\operatorname{Tor}(\ZZ/101, M)$.

+--------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..f];                                                    |
+--------------------------------------------------------------------------+
|i2 : I = trim minors(2, genericSymmetricMatrix(S, 3))                     |
|                                                                          |
|             2                               2                    2       |
|o2 = ideal (e  - d*f, c*e - b*f, c*d - b*e, c  - a*f, b*c - a*e, b  - a*d)|
|                                                                          |
|o2 : Ideal of S                                                           |
+--------------------------------------------------------------------------+
|i3 : M = S^1/I;                                                           |
+--------------------------------------------------------------------------+
|i4 : N = coker vars S                                                     |
|                                                                          |
|o4 = cokernel | a b c d e f |                                             |
|                                                                          |
|                            1                                             |
|o4 : S-module, quotient of S                                              |
+--------------------------------------------------------------------------+
|i5 : f1 = torSymmetry(1,M,N)                                              |
|                                                                          |
|o5 = {2} | 0  -1 0  0  0  0  |                                            |
|     {2} | -1 0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  -1 0  |                                            |
|     {2} | 0  0  0  -1 0  0  |                                            |
|     {2} | 0  0  -1 0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  -1 |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|     {2} | 0  0  0  0  0  0  |                                            |
|                                                                          |
|o5 : Matrix                                                               |
+--------------------------------------------------------------------------+
|i6 : f2 = torSymmetry(1,N,M)                                              |
|                                                                          |
|o6 = {2} | 0  -1 0 0  0  0  0  0 0  0 0 0  0 0  0 0 0 0 0 0 0 |           |
|     {2} | -1 0  0 0  0  0  -1 0 0  0 0 0  0 0  0 0 0 0 0 0 0 |           |
|     {2} | 0  0  0 0  0  -1 0  0 0  0 0 0  0 0  0 0 0 0 0 0 0 |           |
|     {2} | 0  0  0 0  -1 0  0  0 -1 0 0 0  0 0  0 0 0 0 0 0 0 |           |
|     {2} | 0  0  0 -1 0  0  0  0 0  0 0 0  0 -1 0 0 0 0 0 0 0 |           |
|     {2} | 0  0  0 0  0  0  0  0 0  0 0 -1 0 0  0 0 0 0 0 0 0 |           |
|                                                                          |
|o6 : Matrix                                                               |
+--------------------------------------------------------------------------+
|i7 : assert(f1 * f2 == 1)                                                 |
+--------------------------------------------------------------------------+
|i8 : assert(f2 * f1 == 1)                                                 |
+--------------------------------------------------------------------------+
|i9 : g1 = torSymmetry(2,M,N);                                             |
|                                                                          |
|o9 : Matrix                                                               |
+--------------------------------------------------------------------------+
|i10 : g2 = torSymmetry(2,N,M);                                            |
|                                                                          |
|o10 : Matrix                                                              |
+--------------------------------------------------------------------------+
|i11 : assert(g1 * g2 == 1)                                                |
+--------------------------------------------------------------------------+
|i12 : assert(g2 * g1 == 1)                                                |
+--------------------------------------------------------------------------+
|i13 : h1 = torSymmetry(3,M,N);                                            |
|                                                                          |
|o13 : Matrix                                                              |
+--------------------------------------------------------------------------+
|i14 : h2 = torSymmetry(3,N,M);                                            |
|                                                                          |
|o14 : Matrix                                                              |
+--------------------------------------------------------------------------+
|i15 : assert(h1 * h2 == 1)                                                |
+--------------------------------------------------------------------------+
|i16 : assert(h2 * h1 == 1)                                                |
+--------------------------------------------------------------------------+

Although the Tor modules are isomorphic, they are presented with different
numbers of generators.  As a consequence, the matrices need not be square. For
example, after pruning the modules, $f_1$ and $f_2$ are represented by the same
matrix.

+-------------------------------+
|i17 : p1 = prune f1            |
|                               |
|o17 = {2} | -1 0  0  0  0  0  ||
|      {2} | 0  0  -1 0  0  0  ||
|      {2} | 0  -1 0  0  0  0  ||
|      {2} | 0  0  0  -1 0  0  ||
|      {2} | 0  0  0  0  0  -1 ||
|      {2} | 0  0  0  0  -1 0  ||
|                               |
|o17 : Matrix                   |
+-------------------------------+
|i18 : p2 = prune f2            |
|                               |
|o18 = {2} | -1 0  0  0  0  0  ||
|      {2} | 0  0  -1 0  0  0  ||
|      {2} | 0  -1 0  0  0  0  ||
|      {2} | 0  0  0  -1 0  0  ||
|      {2} | 0  0  0  0  0  -1 ||
|      {2} | 0  0  0  0  -1 0  ||
|                               |
|o18 : Matrix                   |
+-------------------------------+
|i19 : assert(p1 * p2 == 1)     |
+-------------------------------+

See also
========

  * Working with Tor -- information about functorial
    properties
  * Tor (Macaulay2Doc) -- Tor module

Ways to use this method:
========================

  * torSymmetry(ZZ,Module,Module),
    -- makes the canonical isomorphism realizing the symmetry of Tor

Towards computing in the derived category
*****************************************

  * resolution(Complex) -- minimal free
    resolution of a complex
  * resolutionMap(Complex) -- map from a free resolution
    to the given complex
  * isShortExactSequence(ComplexMap,ComplexMap)
    -- whether a pair of
    complex maps forms a short exact sequence
  * isQuasiIsomorphism(ComplexMap),
    -- whether a map of complexes is a quasi-isomorphism
  * liftMapAlongQuasiIsomorphism(ComplexMap,ComplexMap)
    -- lift a map of
    chain complexes along a quasi-isomorphism
  * connectingMap(ComplexMap,ComplexMap)
    -- construct the connecting
    homomorphism on homology
  * longExactSequence(ComplexMap,ComplexMap)
    -- make the long exact
    sequence in homology
  * horseshoeResolution(Complex), --
    make the horseshoe resolution

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * Basic invariants and properties, --
    information about accessing basic features
  * Working with Ext -- information about functorial
    properties
  * Working with Tor -- information about functorial
    properties

truncate(List,Complex) -- truncation of a complex at a specified degree or set of degrees
*****************************************************************************************

Synopsis
========

  * Function: truncate (Macaulay2Doc),
  * Usage:
        truncate(d, C)
  * Inputs:
      * d, a list (Macaulay2Doc), or ZZ (Macaulay2Doc),
        if the underlying ring $R$ is singly graded.
      * C, a complex, that is homogeneous over $R$
  * Outputs:
      * a complex, a complex whose terms consist of all
        elements of component-wise degree at least d.

Description
===========

Truncation of homogeneous (graded) modules induces a natural operation on chain
complexes.

In the singly graded case, the truncation of a homogeneous module $M$ at degree
$d$ is generated by all homogeneous elements of degree at least $d$ in $M$.
This method applies this operation to each term in a chain complex.

+-----------------------------------------------------------------------------+
|i1 : R = QQ[a,b,c];                                                          |
+-----------------------------------------------------------------------------+
|i2 : I = ideal(a*b, a*c, b*c)                                                |
|                                                                             |
|o2 = ideal (a*b, a*c, b*c)                                                   |
|                                                                             |
|o2 : Ideal of R                                                              |
+-----------------------------------------------------------------------------+
|i3 : C = freeResolution I                                                    |
|                                                                             |
|      1      3      2                                                        |
|o3 = R  <-- R  <-- R                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : D = truncate(3,C)                                                       |
|                                                                             |
|                                                                             |
|o4 = image | c3 bc2 ac2 b2c abc a2c b3 ab2 a2b a3 | <-- image {2} | c b a 0 0|
|                                                              {2} | 0 0 0 c b|
|     0                                                        {2} | 0 0 0 0 0|
|                                                                             |
|                                                        1                    |
|                                                                             |
|o4 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|               2                                                             |
|0 0 0 0 | <-- R                                                              |
|a 0 0 0 |                                                                    |
|0 c b a |     2                                                              |
+-----------------------------------------------------------------------------+
|i5 : assert isWellDefined D                                                  |
+-----------------------------------------------------------------------------+
|i6 : prune HH D                                                              |
|                                                                             |
|o6 = cokernel {3} | b a 0 0 0 0 |                                            |
|              {3} | 0 0 c a 0 0 |                                            |
|              {3} | 0 0 0 0 c b |                                            |
|                                                                             |
|     0                                                                       |
|                                                                             |
|o6 : Complex                                                                 |
+-----------------------------------------------------------------------------+

Truncating at a degree less than the minimal generators is the identity
operation.

+--------------------------------+
|i7 : assert(C == truncate(0, C))|
+--------------------------------+

In the multi-graded case, the truncation of a homogeneous module at a list of
degrees is generated by all homogeneous elements of degree that are
component-wise greater than or equal to at least one of the degrees.

+-----------------------------------------------------------------------------+
|i8 : A = ZZ/101[x_0, x_1, y_0, y_1, y_2, Degrees => {2:{1,0}, 3:{0,1}}];     |
+-----------------------------------------------------------------------------+
|i9 : I = intersect(ideal(x_0, x_1), ideal(y_0, y_1, y_2))                    |
|                                                                             |
|o9 = ideal (x y , x y , x y , x y , x y , x y )                              |
|             1 2   0 2   1 1   0 1   1 0   0 0                               |
|                                                                             |
|o9 : Ideal of A                                                              |
+-----------------------------------------------------------------------------+
|i10 : C = freeResolution I                                                   |
|                                                                             |
|       1      6      9      5      1                                         |
|o10 = A  <-- A  <-- A  <-- A  <-- A                                          |
|                                                                             |
|      0      1      2      3      4                                          |
|                                                                             |
|o10 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i11 : D1 = prune truncate({{1,1}}, C)                                        |
|                                                                             |
|                                                                            6|
|o11 = cokernel {1, 1} | x_0  y_1  0    0    y_0  0    0    0    0    | <-- A |
|               {1, 1} | -x_1 0    y_1  0    0    0    y_0  0    0    |       |
|               {1, 1} | 0    -y_2 0    x_0  0    y_0  0    0    0    |     1 |
|               {1, 1} | 0    0    -y_2 -x_1 0    0    0    y_0  0    |       |
|               {1, 1} | 0    0    0    0    -y_2 -y_1 0    0    x_0  |       |
|               {1, 1} | 0    0    0    0    0    0    -y_2 -y_1 -x_1 |       |
|                                                                             |
|      0                                                                      |
|                                                                             |
|o11 : Complex                                                                |
|-----------------------------------------------------------------------------|
|     9      5      1                                                         |
|<-- A  <-- A  <-- A                                                          |
|                                                                             |
|    2      3      4                                                          |
+-----------------------------------------------------------------------------+
|i12 : D2 = truncate({{1,0}}, C)                                              |
|                                                                             |
|o12 = image | x_1 x_0 | <-- image {1, 1} | 1 0 0 0 0 0 | <-- image {2, 1} | 1|
|                                  {1, 1} | 0 1 0 0 0 0 |           {2, 1} | 0|
|      0                           {1, 1} | 0 0 1 0 0 0 |           {1, 2} | 0|
|                                  {1, 1} | 0 0 0 1 0 0 |           {1, 2} | 0|
|                                  {1, 1} | 0 0 0 0 1 0 |           {2, 1} | 0|
|                                  {1, 1} | 0 0 0 0 0 1 |           {1, 2} | 0|
|                                                                   {1, 2} | 0|
|                            1                                      {1, 2} | 0|
|                                                                   {1, 2} | 0|
|                                                                             |
|                                                             2               |
|                                                                             |
|o12 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0 0 0 0 0 0 0 0 | <-- image {2, 2} | 1 0 0 0 0 | <-- image {2, 3} | 1 |      |
|1 0 0 0 0 0 0 0 |           {2, 2} | 0 1 0 0 0 |                             |
|0 1 0 0 0 0 0 0 |           {2, 2} | 0 0 1 0 0 |     4                       |
|0 0 1 0 0 0 0 0 |           {1, 3} | 0 0 0 1 0 |                             |
|0 0 0 1 0 0 0 0 |           {1, 3} | 0 0 0 0 1 |                             |
|0 0 0 0 1 0 0 0 |                                                            |
|0 0 0 0 0 1 0 0 |     3                                                      |
|0 0 0 0 0 0 1 0 |                                                            |
|0 0 0 0 0 0 0 1 |                                                            |
+-----------------------------------------------------------------------------+
|i13 : D3 = truncate({{0,1}}, C)                                              |
|                                                                             |
|o13 = image | y_2 y_1 y_0 | <-- image {1, 1} | 1 0 0 0 0 0 | <-- image {2, 1}|
|                                      {1, 1} | 0 1 0 0 0 0 |           {2, 1}|
|      0                               {1, 1} | 0 0 1 0 0 0 |           {1, 2}|
|                                      {1, 1} | 0 0 0 1 0 0 |           {1, 2}|
|                                      {1, 1} | 0 0 0 0 1 0 |           {2, 1}|
|                                      {1, 1} | 0 0 0 0 0 1 |           {1, 2}|
|                                                                       {1, 2}|
|                                1                                      {1, 2}|
|                                                                       {1, 2}|
|                                                                             |
|                                                                 2           |
|                                                                             |
|o13 : Complex                                                                |
|-----------------------------------------------------------------------------|
|| 1 0 0 0 0 0 0 0 0 | <-- image {2, 2} | 1 0 0 0 0 | <-- image {2, 3} | 1 |  |
|| 0 1 0 0 0 0 0 0 0 |           {2, 2} | 0 1 0 0 0 |                         |
|| 0 0 1 0 0 0 0 0 0 |           {2, 2} | 0 0 1 0 0 |     4                   |
|| 0 0 0 1 0 0 0 0 0 |           {1, 3} | 0 0 0 1 0 |                         |
|| 0 0 0 0 1 0 0 0 0 |           {1, 3} | 0 0 0 0 1 |                         |
|| 0 0 0 0 0 1 0 0 0 |                                                        |
|| 0 0 0 0 0 0 1 0 0 |     3                                                  |
|| 0 0 0 0 0 0 0 1 0 |                                                        |
|| 0 0 0 0 0 0 0 0 1 |                                                        |
+-----------------------------------------------------------------------------+
|i14 : D4 = truncate({{1,0},{0,1}}, C)                                        |
|                                                                             |
|o14 = image | y_2 y_1 y_0 x_1 x_0 | <-- image {1, 1} | 1 0 0 0 0 0 | <--     |
|                                              {1, 1} | 0 1 0 0 0 0 |         |
|      0                                       {1, 1} | 0 0 1 0 0 0 |         |
|                                              {1, 1} | 0 0 0 1 0 0 |         |
|                                              {1, 1} | 0 0 0 0 1 0 |         |
|                                              {1, 1} | 0 0 0 0 0 1 |         |
|                                                                             |
|                                        1                                    |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o14 : Complex                                                                |
|-----------------------------------------------------------------------------|
|image {2, 1} | 1 0 0 0 0 0 0 0 0 | <-- image {2, 2} | 1 0 0 0 0 | <-- image  |
|      {2, 1} | 0 1 0 0 0 0 0 0 0 |           {2, 2} | 0 1 0 0 0 |            |
|      {1, 2} | 0 0 1 0 0 0 0 0 0 |           {2, 2} | 0 0 1 0 0 |     4      |
|      {1, 2} | 0 0 0 1 0 0 0 0 0 |           {1, 3} | 0 0 0 1 0 |            |
|      {2, 1} | 0 0 0 0 1 0 0 0 0 |           {1, 3} | 0 0 0 0 1 |            |
|      {1, 2} | 0 0 0 0 0 1 0 0 0 |                                           |
|      {1, 2} | 0 0 0 0 0 0 1 0 0 |     3                                     |
|      {1, 2} | 0 0 0 0 0 0 0 1 0 |                                           |
|      {1, 2} | 0 0 0 0 0 0 0 0 1 |                                           |
|                                                                             |
|2                                                                            |
|-----------------------------------------------------------------------------|
|{2, 3} | 1 |                                                                 |
+-----------------------------------------------------------------------------+
|i15 : D5 = truncate({{2,2}}, C)                                              |
|                                                                             |
|o15 = image | x_1^2y_2^2 x_0x_1y_2^2 x_0^2y_2^2 x_1^2y_1y_2 x_0x_1y_1y_2     |
|                                                                             |
|      0                                                                      |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o15 : Complex                                                                |
|-----------------------------------------------------------------------------|
|x_0^2y_1y_2 x_1^2y_0y_2 x_0x_1y_0y_2 x_0^2y_0y_2 x_1^2y_1^2 x_0x_1y_1^2      |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|x_0^2y_1^2 x_1^2y_0y_1 x_0x_1y_0y_1 x_0^2y_0y_1 x_1^2y_0^2 x_0x_1y_0^2       |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|x_0^2y_0^2 | <-- image {1, 1} | x_1y_2 x_0y_2 x_1y_1 x_0y_1 x_1y_0 x_0y_0    |
|                       {1, 1} | 0      0      0      0      0      0         |
|                       {1, 1} | 0      0      0      0      0      0         |
|                       {1, 1} | 0      0      0      0      0      0         |
|                       {1, 1} | 0      0      0      0      0      0         |
|                       {1, 1} | 0      0      0      0      0      0         |
|                                                                             |
|                 1                                                           |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|0      0      0      0      0      0      0      0      0      0      0      |
|x_1y_2 x_0y_2 x_1y_1 x_0y_1 x_1y_0 x_0y_0 0      0      0      0      0      |
|0      0      0      0      0      0      x_1y_2 x_0y_2 x_1y_1 x_0y_1 x_1y_0 |
|0      0      0      0      0      0      0      0      0      0      0      |
|0      0      0      0      0      0      0      0      0      0      0      |
|0      0      0      0      0      0      0      0      0      0      0      |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|0      0      0      0      0      0      0      0      0      0      0      |
|0      0      0      0      0      0      0      0      0      0      0      |
|x_0y_0 0      0      0      0      0      0      0      0      0      0      |
|0      x_1y_2 x_0y_2 x_1y_1 x_0y_1 x_1y_0 x_0y_0 0      0      0      0      |
|0      0      0      0      0      0      0      x_1y_2 x_0y_2 x_1y_1 x_0y_1 |
|0      0      0      0      0      0      0      0      0      0      0      |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|-----------------------------------------------------------------------------|
|0      0      0      0      0      0      0      0      | <-- image {2, 1} | |
|0      0      0      0      0      0      0      0      |           {2, 1} | |
|0      0      0      0      0      0      0      0      |           {1, 2} | |
|0      0      0      0      0      0      0      0      |           {1, 2} | |
|x_1y_0 x_0y_0 0      0      0      0      0      0      |           {2, 1} | |
|0      0      x_1y_2 x_0y_2 x_1y_1 x_0y_1 x_1y_0 x_0y_0 |           {1, 2} | |
|                                                                    {1, 2} | |
|                                                                    {1, 2} | |
|                                                                    {1, 2} | |
|                                                                             |
|                                                              2              |
|-----------------------------------------------------------------------------|
|y_2 y_1 y_0 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0    |
|0   0   0   y_2 y_1 y_0 0   0   0   0   0   0   0   0   0   0   0   0   0    |
|0   0   0   0   0   0   x_1 x_0 0   0   0   0   0   0   0   0   0   0   0    |
|0   0   0   0   0   0   0   0   x_1 x_0 0   0   0   0   0   0   0   0   0    |
|0   0   0   0   0   0   0   0   0   0   y_2 y_1 y_0 0   0   0   0   0   0    |
|0   0   0   0   0   0   0   0   0   0   0   0   0   x_1 x_0 0   0   0   0    |
|0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   x_1 x_0 0   0    |
|0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   x_1 x_0  |
|0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0    |
|-----------------------------------------------------------------------------|
|0   0   | <-- image {2, 2} | 1 0 0 0   0   0   0   | <-- image {2, 3} | 1 |  |
|0   0   |           {2, 2} | 0 1 0 0   0   0   0   |                         |
|0   0   |           {2, 2} | 0 0 1 0   0   0   0   |     4                   |
|0   0   |           {1, 3} | 0 0 0 x_1 x_0 0   0   |                         |
|0   0   |           {1, 3} | 0 0 0 0   0   x_1 x_0 |                         |
|0   0   |                                                                    |
|0   0   |     3                                                              |
|0   0   |                                                                    |
|x_1 x_0 |                                                                    |
+-----------------------------------------------------------------------------+
|i16 : assert all({D1,D2,D3,D4,D5}, isWellDefined)                            |
+-----------------------------------------------------------------------------+

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * truncate(List,Module) (missing documentation)
  * truncate(List,ComplexMap), --
    truncation of a complex map at a specified degree or set of degrees
  * canonicalTruncation(Complex,Sequence)
    -- reducing the number of
    non-zero terms of a complex
  * naiveTruncation(Complex,ZZ,ZZ)
    -- drops all terms of a complex
    outside a given interval
  * part(List,Complex) -- extract a graded
    component of a complex

Ways to use this method:
========================

  * truncate(List,Complex) -- truncation
    of a complex at a specified degree or set of degrees
  * "truncate(ZZ,Complex)"

truncate(List,ComplexMap) -- truncation of a complex map at a specified degree or set of degrees
************************************************************************************************

Synopsis
========

  * Function: truncate (Macaulay2Doc),
  * Usage:
        truncate(d, f)
  * Inputs:
      * d, a list (Macaulay2Doc), or ZZ (Macaulay2Doc),
        if the underlying ring $R$ is singly graded.
      * f, a map of complexes, that is homogeneous over $R$
  * Outputs:
      * a map of complexes, a complex map over $R$ whose
        terms in the source and target consist of all elements of
        component-wise degree at least d.

Description
===========

Truncation of homogeneous (graded) maps induces a natural operation on maps of
chain complexes.

In the singly graded case, the truncation of a homogeneous module $M$ at degree
$d$ is generated by all homogeneous elements of degree at least $d$ in $M$.
The truncation of a map between homogeneous modules is the induced map between
the truncation of the source and the truncation of the target.  This method
applies this operation to each term in a map of chain complexes.

+-----------------------------------------------------------------------------+
|i1 : R = QQ[a,b,c];                                                          |
+-----------------------------------------------------------------------------+
|i2 : C = freeResolution ideal(a*b, a*c, b*c)                                 |
|                                                                             |
|      1      3      2                                                        |
|o2 = R  <-- R  <-- R                                                         |
|                                                                             |
|     0      1      2                                                         |
|                                                                             |
|o2 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i3 : D = (freeResolution ideal(a*b, a*c, b*c, a^2-b^2))[-1]                  |
|                                                                             |
|      1      4      4      1                                                 |
|o3 = R  <-- R  <-- R  <-- R                                                  |
|                                                                             |
|     1      2      3      4                                                  |
|                                                                             |
|o3 : Complex                                                                 |
+-----------------------------------------------------------------------------+
|i4 : f = randomComplexMap(D,C, Cycle => true)                                |
|                                                                             |
|                   1                                                         |
|o4 = 0 : 0 <----- R  : 0                                                     |
|              0                                                              |
|                                                                             |
|          1                                                                  |
|     1 : R  <----------------------------------------------------------------|
|               | 9/2a2+ab+b2+9/4ac+3/4bc 7/9a2+7/10ab+6b2+13/14ac+5/2bc+6/7c2|
|                                                                             |
|          4                                                    2             |
|     2 : R  <------------------------------------------------ R  : 2         |
|               {2} | 6b-c              -2a-6b-5/4c        |                  |
|               {2} | -61/9a-7/10b-7/6c 95/18a-41/20b-5/4c |                  |
|               {2} | 11/2a+7/6b+9/4c   11/20a-7/3b-7c     |                  |
|               {2} | 1/14a-5/2b-3/28c  3/7a+5/4b+6/7c     |                  |
|                                                                             |
|o4 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                         3                                   |
|--------------------------------------- R  : 1                               |
| 2a2+3/2ab+3/4b2+7/10ac+49/12bc+7c2 |                                        |
+-----------------------------------------------------------------------------+
|i5 : g = truncate(3,f)                                                       |
|                                                                             |
|o5 = 1 : image | c3 bc2 ac2 b2c abc a2c b3 ab2                               |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|     2 : image {2} | c b a 0 0 0 0 0 0 0 0 0 |                               |
|               {2} | 0 0 0 c b a 0 0 0 0 0 0 |                               |
|               {2} | 0 0 0 0 0 0 c b a 0 0 0 |                               |
|               {2} | 0 0 0 0 0 0 0 0 0 c b a |                               |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o5 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|a2b a3 | <----------------------------------------------------------- image  |
|            {3} | 0   0   0   6/7   0     0     7     0     0     |          |
|            {3} | 3/4 0   0   5/2   6/7   0     49/12 7     0     |          |
|            {3} | 9/4 0   0   13/14 0     6/7   7/10  0     7     |          |
|            {3} | 1   3/4 0   6     5/2   0     3/4   49/12 0     |          |
|            {3} | 1   9/4 3/4 7/10  13/14 5/2   3/2   7/10  49/12 |          |
|            {3} | 9/2 0   9/4 7/9   0     13/14 2     0     7/10  |          |
|            {3} | 0   1   0   0     6     0     0     3/4   0     |          |
|            {3} | 0   1   1   0     7/10  6     0     3/2   3/4   |          |
|            {3} | 0   9/2 1   0     7/9   7/10  0     2     3/2   |          |
|            {3} | 0   0   9/2 0     0     7/9   0     0     2     |          |
|                                                                             |
|                           2                                                 |
|<------------------------ R  : 2                                             |
|   {3} | -1    -5/4   |                                                      |
|   {3} | 6     -6     |                                                      |
|   {3} | 0     -2     |                                                      |
|   {3} | -7/6  -5/4   |                                                      |
|   {3} | -7/10 -41/20 |                                                      |
|   {3} | -61/9 95/18  |                                                      |
|   {3} | 9/4   -7     |                                                      |
|   {3} | 7/6   -7/3   |                                                      |
|   {3} | 11/2  11/20  |                                                      |
|   {3} | -3/28 6/7    |                                                      |
|   {3} | -5/2  5/4    |                                                      |
|   {3} | 1/14  3/7    |                                                      |
|-----------------------------------------------------------------------------|
|{2} | c b a 0 0 0 0 0 0 | : 1                                                |
|{2} | 0 0 0 c b a 0 0 0 |                                                    |
|{2} | 0 0 0 0 0 0 c b a |                                                    |
+-----------------------------------------------------------------------------+
|i6 : assert isWellDefined g                                                  |
+-----------------------------------------------------------------------------+
|i7 : assert (source g == truncate(3, source f))                              |
+-----------------------------------------------------------------------------+
|i8 : assert (target g == truncate(3, target f))                              |
+-----------------------------------------------------------------------------+

Truncating at a degree less than the minimal generators is the identity
operation.

+--------------------------------+
|i9 : assert(f == truncate(0, f))|
+--------------------------------+

In the multi-graded case, the truncation of a homogeneous module at a list of
degrees is generated by all homogeneous elements of degree that are
component-wise greater than or equal to at least one of the degrees.  As in the
singly graded case, this induces a map between the truncations the source and
target.

+-----------------------------------------------------------------------------+
|i10 : A = ZZ/101[x_0, x_1, y_0, y_1, y_2, Degrees => {2:{1,0}, 3:{0,1}}];    |
+-----------------------------------------------------------------------------+
|i11 : I = intersect(ideal(x_0, x_1), ideal(y_0, y_1, y_2))                   |
|                                                                             |
|o11 = ideal (x y , x y , x y , x y , x y , x y )                             |
|              1 2   0 2   1 1   0 1   1 0   0 0                              |
|                                                                             |
|o11 : Ideal of A                                                             |
+-----------------------------------------------------------------------------+
|i12 : C = freeResolution I                                                   |
|                                                                             |
|       1      6      9      5      1                                         |
|o12 = A  <-- A  <-- A  <-- A  <-- A                                          |
|                                                                             |
|      0      1      2      3      4                                          |
|                                                                             |
|o12 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i13 : J = intersect(ideal(x_0^2, x_1^2), ideal(y_0^2, y_1^2, y_2^2))         |
|                                                                             |
|              2 2   2 2   2 2   2 2   2 2   2 2                              |
|o13 = ideal (x y , x y , x y , x y , x y , x y )                             |
|              1 2   0 2   1 1   0 1   1 0   0 0                              |
|                                                                             |
|o13 : Ideal of A                                                             |
+-----------------------------------------------------------------------------+
|i14 : D = freeResolution J                                                   |
|                                                                             |
|       1      6      9      5      1                                         |
|o14 = A  <-- A  <-- A  <-- A  <-- A                                          |
|                                                                             |
|      0      1      2      3      4                                          |
|                                                                             |
|o14 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i15 : f = extend(C, D, id_(A^1))                                             |
|                                                                             |
|           1             1                                                   |
|o15 = 0 : A  <--------- A  : 0                                               |
|                | 1 |                                                        |
|                                                                             |
|           6                                                            6    |
|      1 : A  <-------------------------------------------------------- A  : 1|
|                {1, 1} | x_0y_0 0      0      0      0      0      |         |
|                {1, 1} | 0      x_1y_0 0      0      0      0      |         |
|                {1, 1} | 0      0      x_0y_1 0      0      0      |         |
|                {1, 1} | 0      0      0      x_1y_1 0      0      |         |
|                {1, 1} | 0      0      0      0      x_0y_2 0      |         |
|                {1, 1} | 0      0      0      0      0      x_1y_2 |         |
|                                                                             |
|           9                                                                 |
|      2 : A  <---------------------------------------------------------------|
|                {2, 1} | x_0x_1y_0 0         0         0         0         0 |
|                {2, 1} | 0         x_0x_1y_1 0         0         0         0 |
|                {1, 2} | 0         0         x_0y_0y_1 0         0         0 |
|                {1, 2} | 0         0         0         x_1y_0y_1 0         0 |
|                {2, 1} | 0         0         0         0         x_0x_1y_2 0 |
|                {1, 2} | 0         0         0         0         0         x_|
|                {1, 2} | 0         0         0         0         0         0 |
|                {1, 2} | 0         0         0         0         0         0 |
|                {1, 2} | 0         0         0         0         0         0 |
|                                                                             |
|           5                                                                 |
|      3 : A  <---------------------------------------------------------------|
|                {2, 2} | x_0x_1y_0y_1 0            0            0            |
|                {2, 2} | 0            x_0x_1y_0y_2 0            0            |
|                {2, 2} | 0            0            x_0x_1y_1y_2 0            |
|                {1, 3} | 0            0            0            x_0y_0y_1y_2 |
|                {1, 3} | 0            0            0            0            |
|                                                                             |
|           1                                  1                              |
|      4 : A  <------------------------------ A  : 4                          |
|                {2, 3} | x_0x_1y_0y_1y_2 |                                   |
|                                                                             |
|o15 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|                                           9                                 |
|----------------------------------------- A  : 2                             |
|        0         0         0         |                                      |
|        0         0         0         |                                      |
|        0         0         0         |                                      |
|        0         0         0         |                                      |
|        0         0         0         |                                      |
|0y_0y_2 0         0         0         |                                      |
|        x_1y_0y_2 0         0         |                                      |
|        0         x_0y_1y_2 0         |                                      |
|        0         0         x_1y_1y_2 |                                      |
|                                                                             |
|                  5                                                          |
|---------------- A  : 3                                                      |
|0            |                                                               |
|0            |                                                               |
|0            |                                                               |
|0            |                                                               |
|x_1y_0y_1y_2 |                                                               |
+-----------------------------------------------------------------------------+
|i16 : g1 = prune truncate({{1,1}}, f)                                        |
|                                                                             |
|o16 = 0 : cokernel {1, 1} | x_0  y_1  0    0    y_0  0    0    0    0    | <-|
|                   {1, 1} | -x_1 0    y_1  0    0    0    y_0  0    0    |   |
|                   {1, 1} | 0    -y_2 0    x_0  0    y_0  0    0    0    |   |
|                   {1, 1} | 0    0    -y_2 -x_1 0    0    0    y_0  0    |   |
|                   {1, 1} | 0    0    0    0    -y_2 -y_1 0    0    x_0  |   |
|                   {1, 1} | 0    0    0    0    0    0    -y_2 -y_1 -x_1 |   |
|                                                                             |
|                                                                             |
|           6                                                            6    |
|      1 : A  <-------------------------------------------------------- A  : 1|
|                {1, 1} | x_0y_0 0      0      0      0      0      |         |
|                {1, 1} | 0      x_1y_0 0      0      0      0      |         |
|                {1, 1} | 0      0      x_0y_1 0      0      0      |         |
|                {1, 1} | 0      0      0      x_1y_1 0      0      |         |
|                {1, 1} | 0      0      0      0      x_0y_2 0      |         |
|                {1, 1} | 0      0      0      0      0      x_1y_2 |         |
|                                                                             |
|           9                                                                 |
|      2 : A  <---------------------------------------------------------------|
|                {2, 1} | x_0x_1y_0 0         0         0         0         0 |
|                {2, 1} | 0         x_0x_1y_1 0         0         0         0 |
|                {1, 2} | 0         0         x_0y_0y_1 0         0         0 |
|                {1, 2} | 0         0         0         x_1y_0y_1 0         0 |
|                {2, 1} | 0         0         0         0         x_0x_1y_2 0 |
|                {1, 2} | 0         0         0         0         0         x_|
|                {1, 2} | 0         0         0         0         0         0 |
|                {1, 2} | 0         0         0         0         0         0 |
|                {1, 2} | 0         0         0         0         0         0 |
|                                                                             |
|           5                                                                 |
|      3 : A  <---------------------------------------------------------------|
|                {2, 2} | x_0x_1y_0y_1 0            0            0            |
|                {2, 2} | 0            x_0x_1y_0y_2 0            0            |
|                {2, 2} | 0            0            x_0x_1y_1y_2 0            |
|                {1, 3} | 0            0            0            x_0y_0y_1y_2 |
|                {1, 3} | 0            0            0            0            |
|                                                                             |
|           1                                  1                              |
|      4 : A  <------------------------------ A  : 4                          |
|                {2, 3} | x_0x_1y_0y_1y_2 |                                   |
|                                                                             |
|o16 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|------------------------- cokernel {1, 1} | x_0  y_1  0    0    y_0  0       |
| {1, 1} | 1 0 0 0 0 0 |            {1, 1} | -x_1 0    y_1  0    0    0       |
| {1, 1} | 0 1 0 0 0 0 |            {1, 1} | 0    -y_2 0    x_0  0    y_0     |
| {1, 1} | 0 0 1 0 0 0 |            {1, 1} | 0    0    -y_2 -x_1 0    0       |
| {1, 1} | 0 0 0 1 0 0 |            {1, 1} | 0    0    0    0    -y_2 -y_1    |
| {1, 1} | 0 0 0 0 1 0 |            {1, 1} | 0    0    0    0    0    0       |
| {1, 1} | 0 0 0 0 0 1 |                                                      |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                           9                                 |
|----------------------------------------- A  : 2                             |
|        0         0         0         |                                      |
|        0         0         0         |                                      |
|        0         0         0         |                                      |
|        0         0         0         |                                      |
|        0         0         0         |                                      |
|0y_0y_2 0         0         0         |                                      |
|        x_1y_0y_2 0         0         |                                      |
|        0         x_0y_1y_2 0         |                                      |
|        0         0         x_1y_1y_2 |                                      |
|                                                                             |
|                  5                                                          |
|---------------- A  : 3                                                      |
|0            |                                                               |
|0            |                                                               |
|0            |                                                               |
|0            |                                                               |
|x_1y_0y_1y_2 |                                                               |
|-----------------------------------------------------------------------------|
|0    0    0    | : 0                                                         |
|y_0  0    0    |                                                             |
|0    0    0    |                                                             |
|0    y_0  0    |                                                             |
|0    0    x_0  |                                                             |
|-y_2 -y_1 -x_1 |                                                             |
+-----------------------------------------------------------------------------+
|i17 : g2 = truncate({{1,0}},                                                 |
|                                                                             |
|o17 = 0 : image | x_1 x_0 |                                                  |
|                                                                             |
|                                                                             |
|                                                                             |
|      1 : image {1, 1} | 1 0                                                 |
|                {1, 1} | 0 1                                                 |
|                {1, 1} | 0 0                                                 |
|                {1, 1} | 0 0                                                 |
|                {1, 1} | 0 0                                                 |
|                {1, 1} | 0 0                                                 |
|                                                                             |
|                                                                             |
|      2 : image {2, 1} | 1 0                                                 |
|                {2, 1} | 0 1                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {2, 1} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                                                                             |
|                                                                             |
|      3 : image {2, 2} | 1 0                                                 |
|                {2, 2} | 0 1                                                 |
|                {2, 2} | 0 0                                                 |
|                {1, 3} | 0 0                                                 |
|                {1, 3} | 0 0                                                 |
|                                                                             |
|                                                                             |
|      4 : image {2, 3} | 1 |                                                 |
|                                                                             |
|                                                                             |
|o17 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
| f)                                                                          |
|                                                                             |
|<------------------ image | x_1 x_0 | : 0                                    |
|   {1, 0} | 1 0 |                                                            |
|   {1, 0} | 0 1 |                                                            |
|                                                                             |
| 0 0 0 0 | <-------------------------------------------------------- image {2|
| 0 0 0 0 |    {1, 1} | x_0y_0 0      0      0      0      0      |         {2|
| 1 0 0 0 |    {1, 1} | 0      x_1y_0 0      0      0      0      |         {2|
| 0 1 0 0 |    {1, 1} | 0      0      x_0y_1 0      0      0      |         {2|
| 0 0 1 0 |    {1, 1} | 0      0      0      x_1y_1 0      0      |         {2|
| 0 0 0 1 |    {1, 1} | 0      0      0      0      x_0y_2 0      |         {2|
|              {1, 1} | 0      0      0      0      0      x_1y_2 |           |
|                                                                             |
| 0 0 0 0 0 0 0 | <-----------------------------------------------------------|
| 0 0 0 0 0 0 0 |    {2, 1} | x_0x_1y_0 0         0         0         0       |
| 1 0 0 0 0 0 0 |    {2, 1} | 0         x_0x_1y_1 0         0         0       |
| 0 1 0 0 0 0 0 |    {1, 2} | 0         0         x_0y_0y_1 0         0       |
| 0 0 1 0 0 0 0 |    {1, 2} | 0         0         0         x_1y_0y_1 0       |
| 0 0 0 1 0 0 0 |    {2, 1} | 0         0         0         0         x_0x_1y_|
| 0 0 0 0 1 0 0 |    {1, 2} | 0         0         0         0         0       |
| 0 0 0 0 0 1 0 |    {1, 2} | 0         0         0         0         0       |
| 0 0 0 0 0 0 1 |    {1, 2} | 0         0         0         0         0       |
|                    {1, 2} | 0         0         0         0         0       |
|                                                                             |
| 0 0 0 | <-------------------------------------------------------------------|
| 0 0 0 |    {2, 2} | x_0x_1y_0y_1 0            0            0            0   |
| 1 0 0 |    {2, 2} | 0            x_0x_1y_0y_2 0            0            0   |
| 0 1 0 |    {2, 2} | 0            0            x_0x_1y_1y_2 0            0   |
| 0 0 1 |    {1, 3} | 0            0            0            x_0y_0y_1y_2 0   |
|            {1, 3} | 0            0            0            0            x_1y|
|                                                                             |
| <------------------------------ image {4, 6} | 1 | : 4                      |
|    {2, 3} | x_0x_1y_0y_1y_2 |                                               |
|-----------------------------------------------------------------------------|
|, 2} | 1 0 0 0 0 0 | : 1                                                     |
|, 2} | 0 1 0 0 0 0 |                                                         |
|, 2} | 0 0 1 0 0 0 |                                                         |
|, 2} | 0 0 0 1 0 0 |                                                         |
|, 2} | 0 0 0 0 1 0 |                                                         |
|, 2} | 0 0 0 0 0 1 |                                                         |
|                                                                             |
|                                                                             |
|--------------------------------------------- image {4, 2} | 1 0 0 0 0 0 0 0 |
|  0         0         0         0         |         {4, 2} | 0 1 0 0 0 0 0 0 |
|  0         0         0         0         |         {2, 4} | 0 0 1 0 0 0 0 0 |
|  0         0         0         0         |         {2, 4} | 0 0 0 1 0 0 0 0 |
|  0         0         0         0         |         {4, 2} | 0 0 0 0 1 0 0 0 |
|2 0         0         0         0         |         {2, 4} | 0 0 0 0 0 1 0 0 |
|  x_0y_0y_2 0         0         0         |         {2, 4} | 0 0 0 0 0 0 1 0 |
|  0         x_1y_0y_2 0         0         |         {2, 4} | 0 0 0 0 0 0 0 1 |
|  0         0         x_0y_1y_2 0         |         {2, 4} | 0 0 0 0 0 0 0 0 |
|  0         0         0         x_1y_1y_2 |                                  |
|                                                                             |
|------------ image {4, 4} | 1 0 0 0 0 | : 3                                  |
|         |         {4, 4} | 0 1 0 0 0 |                                      |
|         |         {4, 4} | 0 0 1 0 0 |                                      |
|         |         {2, 6} | 0 0 0 1 0 |                                      |
|         |         {2, 6} | 0 0 0 0 1 |                                      |
|_0y_1y_2 |                                                                   |
|-----------------------------------------------------------------------------|
|0 | : 2                                                                      |
|0 |                                                                          |
|0 |                                                                          |
|0 |                                                                          |
|0 |                                                                          |
|0 |                                                                          |
|0 |                                                                          |
|0 |                                                                          |
|1 |                                                                          |
+-----------------------------------------------------------------------------+
|i18 : g3 = truncate({{0,1}},                                                 |
|                                                                             |
|o18 = 0 : image | y_2 y_1 y_0                                                |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      1 : image {1, 1} | 1 0                                                 |
|                {1, 1} | 0 1                                                 |
|                {1, 1} | 0 0                                                 |
|                {1, 1} | 0 0                                                 |
|                {1, 1} | 0 0                                                 |
|                {1, 1} | 0 0                                                 |
|                                                                             |
|                                                                             |
|      2 : image {2, 1} | 1 0                                                 |
|                {2, 1} | 0 1                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {2, 1} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                                                                             |
|                                                                             |
|      3 : image {2, 2} | 1 0                                                 |
|                {2, 2} | 0 1                                                 |
|                {2, 2} | 0 0                                                 |
|                {1, 3} | 0 0                                                 |
|                {1, 3} | 0 0                                                 |
|                                                                             |
|                                                                             |
|      4 : image {2, 3} | 1 |                                                 |
|                                                                             |
|                                                                             |
|o18 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|f)                                                                           |
|                                                                             |
| | <-------------------- image | y_2 y_1 y_0 | : 0                           |
|      {0, 1} | 1 0 0 |                                                       |
|      {0, 1} | 0 1 0 |                                                       |
|      {0, 1} | 0 0 1 |                                                       |
|                                                                             |
|0 0 0 0 | <-------------------------------------------------------- image {2,|
|0 0 0 0 |    {1, 1} | x_0y_0 0      0      0      0      0      |         {2,|
|1 0 0 0 |    {1, 1} | 0      x_1y_0 0      0      0      0      |         {2,|
|0 1 0 0 |    {1, 1} | 0      0      x_0y_1 0      0      0      |         {2,|
|0 0 1 0 |    {1, 1} | 0      0      0      x_1y_1 0      0      |         {2,|
|0 0 0 1 |    {1, 1} | 0      0      0      0      x_0y_2 0      |         {2,|
|             {1, 1} | 0      0      0      0      0      x_1y_2 |            |
|                                                                             |
|0 0 0 0 0 0 0 | <------------------------------------------------------------|
|0 0 0 0 0 0 0 |    {2, 1} | x_0x_1y_0 0         0         0         0        |
|1 0 0 0 0 0 0 |    {2, 1} | 0         x_0x_1y_1 0         0         0        |
|0 1 0 0 0 0 0 |    {1, 2} | 0         0         x_0y_0y_1 0         0        |
|0 0 1 0 0 0 0 |    {1, 2} | 0         0         0         x_1y_0y_1 0        |
|0 0 0 1 0 0 0 |    {2, 1} | 0         0         0         0         x_0x_1y_2|
|0 0 0 0 1 0 0 |    {1, 2} | 0         0         0         0         0        |
|0 0 0 0 0 1 0 |    {1, 2} | 0         0         0         0         0        |
|0 0 0 0 0 0 1 |    {1, 2} | 0         0         0         0         0        |
|                   {1, 2} | 0         0         0         0         0        |
|                                                                             |
|0 0 0 | <--------------------------------------------------------------------|
|0 0 0 |    {2, 2} | x_0x_1y_0y_1 0            0            0            0    |
|1 0 0 |    {2, 2} | 0            x_0x_1y_0y_2 0            0            0    |
|0 1 0 |    {2, 2} | 0            0            x_0x_1y_1y_2 0            0    |
|0 0 1 |    {1, 3} | 0            0            0            x_0y_0y_1y_2 0    |
|           {1, 3} | 0            0            0            0            x_1y_|
|                                                                             |
|<------------------------------ image {4, 6} | 1 | : 4                       |
|   {2, 3} | x_0x_1y_0y_1y_2 |                                                |
|-----------------------------------------------------------------------------|
| 2} | 1 0 0 0 0 0 | : 1                                                      |
| 2} | 0 1 0 0 0 0 |                                                          |
| 2} | 0 0 1 0 0 0 |                                                          |
| 2} | 0 0 0 1 0 0 |                                                          |
| 2} | 0 0 0 0 1 0 |                                                          |
| 2} | 0 0 0 0 0 1 |                                                          |
|                                                                             |
|                                                                             |
|-------------------------------------------- image {4, 2} | 1 0 0 0 0 0 0 0 0|
| 0         0         0         0         |         {4, 2} | 0 1 0 0 0 0 0 0 0|
| 0         0         0         0         |         {2, 4} | 0 0 1 0 0 0 0 0 0|
| 0         0         0         0         |         {2, 4} | 0 0 0 1 0 0 0 0 0|
| 0         0         0         0         |         {4, 2} | 0 0 0 0 1 0 0 0 0|
| 0         0         0         0         |         {2, 4} | 0 0 0 0 0 1 0 0 0|
| x_0y_0y_2 0         0         0         |         {2, 4} | 0 0 0 0 0 0 1 0 0|
| 0         x_1y_0y_2 0         0         |         {2, 4} | 0 0 0 0 0 0 0 1 0|
| 0         0         x_0y_1y_2 0         |         {2, 4} | 0 0 0 0 0 0 0 0 1|
| 0         0         0         x_1y_1y_2 |                                   |
|                                                                             |
|----------- image {4, 4} | 1 0 0 0 0 | : 3                                   |
|        |         {4, 4} | 0 1 0 0 0 |                                       |
|        |         {4, 4} | 0 0 1 0 0 |                                       |
|        |         {2, 6} | 0 0 0 1 0 |                                       |
|        |         {2, 6} | 0 0 0 0 1 |                                       |
|0y_1y_2 |                                                                    |
|-----------------------------------------------------------------------------|
|| : 2                                                                        |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i19 : g4 = truncate({{1,0},{0                                                |
|                                                                             |
|o19 = 0 : image | y_2 y_1 y_0                                                |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      1 : image {1, 1} | 1 0                                                 |
|                {1, 1} | 0 1                                                 |
|                {1, 1} | 0 0                                                 |
|                {1, 1} | 0 0                                                 |
|                {1, 1} | 0 0                                                 |
|                {1, 1} | 0 0                                                 |
|                                                                             |
|                                                                             |
|      2 : image {2, 1} | 1 0                                                 |
|                {2, 1} | 0 1                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {2, 1} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                {1, 2} | 0 0                                                 |
|                                                                             |
|                                                                             |
|      3 : image {2, 2} | 1 0                                                 |
|                {2, 2} | 0 1                                                 |
|                {2, 2} | 0 0                                                 |
|                {1, 3} | 0 0                                                 |
|                {1, 3} | 0 0                                                 |
|                                                                             |
|                                                                             |
|      4 : image {2, 3} | 1 |                                                 |
|                                                                             |
|                                                                             |
|o19 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|,1}}, f)                                                                     |
|                                                                             |
| x_1 x_0 | <------------------------ image | y_2 y_1 y_0 x_1 x_0 | : 0       |
|              {0, 1} | 1 0 0 0 0 |                                           |
|              {0, 1} | 0 1 0 0 0 |                                           |
|              {0, 1} | 0 0 1 0 0 |                                           |
|              {1, 0} | 0 0 0 1 0 |                                           |
|              {1, 0} | 0 0 0 0 1 |                                           |
|                                                                             |
|0 0 0 0 | <-------------------------------------------------------- image {2,|
|0 0 0 0 |    {1, 1} | x_0y_0 0      0      0      0      0      |         {2,|
|1 0 0 0 |    {1, 1} | 0      x_1y_0 0      0      0      0      |         {2,|
|0 1 0 0 |    {1, 1} | 0      0      x_0y_1 0      0      0      |         {2,|
|0 0 1 0 |    {1, 1} | 0      0      0      x_1y_1 0      0      |         {2,|
|0 0 0 1 |    {1, 1} | 0      0      0      0      x_0y_2 0      |         {2,|
|             {1, 1} | 0      0      0      0      0      x_1y_2 |            |
|                                                                             |
|0 0 0 0 0 0 0 | <------------------------------------------------------------|
|0 0 0 0 0 0 0 |    {2, 1} | x_0x_1y_0 0         0         0         0        |
|1 0 0 0 0 0 0 |    {2, 1} | 0         x_0x_1y_1 0         0         0        |
|0 1 0 0 0 0 0 |    {1, 2} | 0         0         x_0y_0y_1 0         0        |
|0 0 1 0 0 0 0 |    {1, 2} | 0         0         0         x_1y_0y_1 0        |
|0 0 0 1 0 0 0 |    {2, 1} | 0         0         0         0         x_0x_1y_2|
|0 0 0 0 1 0 0 |    {1, 2} | 0         0         0         0         0        |
|0 0 0 0 0 1 0 |    {1, 2} | 0         0         0         0         0        |
|0 0 0 0 0 0 1 |    {1, 2} | 0         0         0         0         0        |
|                   {1, 2} | 0         0         0         0         0        |
|                                                                             |
|0 0 0 | <--------------------------------------------------------------------|
|0 0 0 |    {2, 2} | x_0x_1y_0y_1 0            0            0            0    |
|1 0 0 |    {2, 2} | 0            x_0x_1y_0y_2 0            0            0    |
|0 1 0 |    {2, 2} | 0            0            x_0x_1y_1y_2 0            0    |
|0 0 1 |    {1, 3} | 0            0            0            x_0y_0y_1y_2 0    |
|           {1, 3} | 0            0            0            0            x_1y_|
|                                                                             |
|<------------------------------ image {4, 6} | 1 | : 4                       |
|   {2, 3} | x_0x_1y_0y_1y_2 |                                                |
|-----------------------------------------------------------------------------|
| 2} | 1 0 0 0 0 0 | : 1                                                      |
| 2} | 0 1 0 0 0 0 |                                                          |
| 2} | 0 0 1 0 0 0 |                                                          |
| 2} | 0 0 0 1 0 0 |                                                          |
| 2} | 0 0 0 0 1 0 |                                                          |
| 2} | 0 0 0 0 0 1 |                                                          |
|                                                                             |
|                                                                             |
|-------------------------------------------- image {4, 2} | 1 0 0 0 0 0 0 0 0|
| 0         0         0         0         |         {4, 2} | 0 1 0 0 0 0 0 0 0|
| 0         0         0         0         |         {2, 4} | 0 0 1 0 0 0 0 0 0|
| 0         0         0         0         |         {2, 4} | 0 0 0 1 0 0 0 0 0|
| 0         0         0         0         |         {4, 2} | 0 0 0 0 1 0 0 0 0|
| 0         0         0         0         |         {2, 4} | 0 0 0 0 0 1 0 0 0|
| x_0y_0y_2 0         0         0         |         {2, 4} | 0 0 0 0 0 0 1 0 0|
| 0         x_1y_0y_2 0         0         |         {2, 4} | 0 0 0 0 0 0 0 1 0|
| 0         0         x_0y_1y_2 0         |         {2, 4} | 0 0 0 0 0 0 0 0 1|
| 0         0         0         x_1y_1y_2 |                                   |
|                                                                             |
|----------- image {4, 4} | 1 0 0 0 0 | : 3                                   |
|        |         {4, 4} | 0 1 0 0 0 |                                       |
|        |         {4, 4} | 0 0 1 0 0 |                                       |
|        |         {2, 6} | 0 0 0 1 0 |                                       |
|        |         {2, 6} | 0 0 0 0 1 |                                       |
|0y_1y_2 |                                                                    |
|-----------------------------------------------------------------------------|
|| : 2                                                                        |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i20 : g5 = truncate({{2,2}},                                                 |
|                                                                             |
|o20 = 0 : image | x_1^2y_2^2                                                 |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      1 : image {1, 1} | x_1y                                                |
|                {1, 1} | 0                                                   |
|                {1, 1} | 0                                                   |
|                {1, 1} | 0                                                   |
|                {1, 1} | 0                                                   |
|                {1, 1} | 0                                                   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      2 : image {2, 1} | y_2                                                 |
|                {2, 1} | 0                                                   |
|                {1, 2} | 0                                                   |
|                {1, 2} | 0                                                   |
|                {2, 1} | 0                                                   |
|                {1, 2} | 0                                                   |
|                {1, 2} | 0                                                   |
|                {1, 2} | 0                                                   |
|                {1, 2} | 0                                                   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      3 : image {2, 2} | 1 0                                                 |
|                {2, 2} | 0 1                                                 |
|                {2, 2} | 0 0                                                 |
|                {1, 3} | 0 0                                                 |
|                {1, 3} | 0 0                                                 |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|      4 : image {2, 3} | 1 |                                                 |
|                                                                             |
|                                                                             |
|o20 : ComplexMap                                                             |
|-----------------------------------------------------------------------------|
|f)                                                                           |
|                                                                             |
|x_0x_1y_2^2 x_0^2y_2^2 x_1^2y_1y_2 x_0x_1y_1y_2 x_0^2y_1y_2 x_1^2y_0y_2 x_0x_|
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|_2 x_0y_2 x_1y_1 x_0y_1 x_1y_0 x_0y_0 0      0      0      0      0      0   |
|   0      0      0      0      0      x_1y_2 x_0y_2 x_1y_1 x_0y_1 x_1y_0 x_0y|
|   0      0      0      0      0      0      0      0      0      0      0   |
|   0      0      0      0      0      0      0      0      0      0      0   |
|   0      0      0      0      0      0      0      0      0      0      0   |
|   0      0      0      0      0      0      0      0      0      0      0   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|y_1 y_0 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0|
|0   0   y_2 y_1 y_0 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0|
|0   0   0   0   0   x_1 x_0 0   0   0   0   0   0   0   0   0   0   0   0   0|
|0   0   0   0   0   0   0   x_1 x_0 0   0   0   0   0   0   0   0   0   0   0|
|0   0   0   0   0   0   0   0   0   y_2 y_1 y_0 0   0   0   0   0   0   0   0|
|0   0   0   0   0   0   0   0   0   0   0   0   x_1 x_0 0   0   0   0   0   0|
|0   0   0   0   0   0   0   0   0   0   0   0   0   0   x_1 x_0 0   0   0   0|
|0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   x_1 x_0 0   0|
|0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   x_1 x|
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|0 0   0   0   0   | <--------------------------------------------------------|
|0 0   0   0   0   |    {2, 2} | x_0x_1y_0y_1 0            0            0     |
|1 0   0   0   0   |    {2, 2} | 0            x_0x_1y_0y_2 0            0     |
|0 x_1 x_0 0   0   |    {2, 2} | 0            0            x_0x_1y_1y_2 0     |
|0 0   0   x_1 x_0 |    {2, 3} | 0            0            0            0     |
|                       {2, 3} | 0            0            0            y_0y_1|
|                       {2, 3} | 0            0            0            0     |
|                       {2, 3} | 0            0            0            0     |
|                                                                             |
|<------------------------------ image {4, 6} | 1 | : 4                       |
|   {2, 3} | x_0x_1y_0y_1y_2 |                                                |
|-----------------------------------------------------------------------------|
|1y_0y_2 x_0^2y_0y_2 x_1^2y_1^2 x_0x_1y_1^2 x_0^2y_1^2 x_1^2y_0y_1 x_0x_1y_0y_|
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|   0      0      0      0      0      0      0      0      0      0      0   |
|_0 0      0      0      0      0      0      0      0      0      0      0   |
|   x_1y_2 x_0y_2 x_1y_1 x_0y_1 x_1y_0 x_0y_0 0      0      0      0      0   |
|   0      0      0      0      0      0      x_1y_2 x_0y_2 x_1y_1 x_0y_1 x_1y|
|   0      0      0      0      0      0      0      0      0      0      0   |
|   0      0      0      0      0      0      0      0      0      0      0   |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|   | <-----------------------------------------------------------------------|
|   |    {2, 2} | 0      0      0      0      0      0      0      0      0   |
|   |    {2, 2} | 0      0      0      0      0      0      0      0      0   |
|   |    {2, 2} | x_0x_1 0      0      0      0      0      0      0      0   |
|   |    {2, 2} | 0      0      0      0      0      0      0      0      0   |
|   |    {2, 2} | 0      x_0x_1 0      0      0      0      0      0      0   |
|   |    {2, 2} | 0      0      0      0      0      0      0      0      0   |
|   |    {2, 2} | 0      0      0      0      0      0      0      0      0   |
|_0 |    {2, 2} | 0      0      y_0y_1 0      0      0      0      0      0   |
|        {2, 2} | 0      0      0      y_0y_1 0      0      0      0      0   |
|        {2, 2} | 0      0      0      0      0      0      0      0      0   |
|        {2, 2} | 0      0      0      0      x_0x_1 0      0      0      0   |
|        {2, 2} | 0      0      0      0      0      0      0      0      0   |
|        {2, 2} | 0      0      0      0      0      0      0      0      0   |
|        {2, 2} | 0      0      0      0      0      0      0      0      0   |
|        {2, 2} | 0      0      0      0      0      y_0y_2 0      0      0   |
|        {2, 2} | 0      0      0      0      0      0      y_0y_2 0      0   |
|        {2, 2} | 0      0      0      0      0      0      0      0      0   |
|        {2, 2} | 0      0      0      0      0      0      0      0      0   |
|        {2, 2} | 0      0      0      0      0      0      0      y_1y_2 0   |
|        {2, 2} | 0      0      0      0      0      0      0      0      y_1y|
|        {2, 2} | 0      0      0      0      0      0      0      0      0   |
|                                                                             |
|----------------- image {4, 4} | 1 0 0 0 0 | : 3                             |
|    0         |         {4, 4} | 0 1 0 0 0 |                                 |
|    0         |         {4, 4} | 0 0 1 0 0 |                                 |
|    0         |         {2, 6} | 0 0 0 1 0 |                                 |
|    0         |         {2, 6} | 0 0 0 0 1 |                                 |
|y_2 0         |                                                              |
|    y_0y_1y_2 |                                                              |
|    0         |                                                              |
|-----------------------------------------------------------------------------|
|1 x_0^2y_0y_1 x_1^2y_0^2 x_0x_1y_0^2 x_0^2y_0^2 |                            |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|   0      0      0      0      0      0      0                               |
|   0      0      0      0      0      0      0                               |
|   0      0      0      0      0      0      0                               |
|_0 x_0y_0 0      0      0      0      0      0                               |
|   0      x_1y_2 x_0y_2 x_1y_1 x_0y_1 x_1y_0 x_0y_                           |
|   0      0      0      0      0      0      0                               |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|------ image {4, 2} | 1 0 0 0 0 0 0 0 0 | : 2                                |
|   |         {4, 2} | 0 1 0 0 0 0 0 0 0 |                                    |
|   |         {2, 4} | 0 0 1 0 0 0 0 0 0 |                                    |
|   |         {2, 4} | 0 0 0 1 0 0 0 0 0 |                                    |
|   |         {4, 2} | 0 0 0 0 1 0 0 0 0 |                                    |
|   |         {2, 4} | 0 0 0 0 0 1 0 0 0 |                                    |
|   |         {2, 4} | 0 0 0 0 0 0 1 0 0 |                                    |
|   |         {2, 4} | 0 0 0 0 0 0 0 1 0 |                                    |
|   |         {2, 4} | 0 0 0 0 0 0 0 0 1 |                                    |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|   |                                                                         |
|_2 |                                                                         |
|   |                                                                         |
|-----------------------------------------------------------------------------|
|<-------------------------------------------------- image | x_1^2y_2^2 x_    |
|   {2, 2} | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 |                            |
|   {2, 2} | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 |                            |
|                                                                             |
|  0      0      0      0      0      0      | <--------------------------    |
|  0      0      0      0      0      0      |    {2, 2} | 0 0 0 0 0 0 |      |
|  0      0      0      0      0      0      |    {2, 2} | 0 0 0 0 0 0 |      |
|  0      0      0      0      0      0      |    {2, 2} | 0 0 0 0 0 0 |      |
|0 0      0      0      0      0      0      |    {2, 2} | 0 0 0 0 0 0 |      |
|  x_1y_2 x_0y_2 x_1y_1 x_0y_1 x_1y_0 x_0y_0 |    {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 1 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 1 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 1 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 1 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 1 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 1 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|                                                 {2, 2} | 0 0 0 0 0 0 |      |
|-----------------------------------------------------------------------------|
|0x_1y_2^2 x_0^2y_2^2 x_1^2y_1y_2 x_0x_1y_1y_2 x_0^2y_1y_2 x_1^2y_0y_2        |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
| image {2, 2} | 1 0 0 0 0 0 | : 1                                            |
|       {2, 2} | 0 1 0 0 0 0 |                                                |
|       {2, 2} | 0 0 1 0 0 0 |                                                |
|       {2, 2} | 0 0 0 1 0 0 |                                                |
|       {2, 2} | 0 0 0 0 1 0 |                                                |
|       {2, 2} | 0 0 0 0 0 1 |                                                |
|-----------------------------------------------------------------------------|
|x_0x_1y_0y_2 x_0^2y_0y_2 x_1^2y_1^2 x_0x_1y_1^2 x_0^2y_1^2 x_1^2y_0y_1       |
|-----------------------------------------------------------------------------|
|x_0x_1y_0y_1 x_0^2y_0y_1 x_1^2y_0^2 x_0x_1y_0^2 x_0^2y_0^2 | : 0             |
+-----------------------------------------------------------------------------+
|i21 : assert all({g1,g2,g3,g4,g5}, isWellDefined)                            |
+-----------------------------------------------------------------------------+

See also
========

  * Making maps between chain complexes
    -- information about the basic constructors
  * truncate(List,Matrix) (missing documentation)
  * truncate(List,Complex) -- truncation
    of a complex at a specified degree or set of degrees
  * canonicalTruncation(ComplexMap,Sequence)
    -- reducing the number of
    non-zero terms of a complex
  * naiveTruncation(ComplexMap,ZZ,ZZ)
    -- drops all terms in the source
    of a complex outside a given interval
  * part(List,ComplexMap) -- extract a
    graded component of a map of complexes

Ways to use this method:
========================

  * truncate(List,ComplexMap), --
    truncation of a complex map at a specified degree or set of degrees
  * "truncate(ZZ,ComplexMap)"

Working with Ext -- information about functorial properties
***********************************************************

Hom and Ext
===========

  * Ext^ZZ(Module,Module) (Macaulay2Doc), --
    Ext module
  * Ext^ZZ(Matrix,Module) (Macaulay2Doc), --
    map between Ext modules
  * Ext^ZZ(Module,Matrix) (Macaulay2Doc), --
    map between Ext modules
  * Hom(Complex,Complex) -- the complex of
    homomorphisms between two complexes
  * Hom(ComplexMap,ComplexMap) -- the
    map of complexes between Hom complexes
  * homomorphism(ComplexMap) -- get the
    homomorphism from an element of Hom
  * homomorphism'(ComplexMap) -- get the
    element of Hom from a map of complexes
  * connectingExtMap(Module,Matrix,Matrix)
    -- makes the connecting
    maps in Ext

Yoneda extensions and elements of Ext
=====================================

  * yonedaMap(Matrix) -- creates a chain complex
    map representing an extension of modules
  * yonedaMap'(ComplexMap) -- identifies the
    element of Ext corresponding to a map of free resolutions
  * yonedaExtension(Matrix) -- creates a
    chain complex representing an extension of modules
  * yonedaExtension'(Complex), --
    identifies the element of Ext corresponding to an extension
  * yonedaProduct(Matrix,Matrix), --
    make the product of two elements in Ext modules
  * yonedaProduct(Module,Module), --
    make the product map between Ext modules

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * Basic invariants and properties, --
    information about accessing basic features
  * Working with Tor -- information about functorial
    properties
  * Towards computing in the derived category

Working with Tor -- information about functorial properties
***********************************************************

  * Tor_ZZ(Module,Module) (Macaulay2Doc),
    -- compute a Tor module
  * Tor_ZZ(Module,Matrix) (missing documentation)
  * Tor_ZZ(Matrix,Module) (missing documentation)
  * tensor(Complex,Complex) -- tensor product of
    complexes
  * tensor(ComplexMap,ComplexMap) -- the
    map of complexes between tensor complexes
  * tensorCommutativity(Complex,Complex)
    -- make the canonical
    isomorphism arising from commutativity
  * tensorAssociativity(Complex,Complex,Complex)
    -- make the canonical
    isomorphism arising from associativity
  * torSymmetry(ZZ,Module,Module),
    -- makes the canonical isomorphism realizing the symmetry of Tor
  * connectingTorMap, --
    makes the connecting maps in Tor

See also
========

  * Making chain complexes -- information about
    the basic constructors
  * Making maps between chain complexes
    -- information about the basic constructors
  * Basic invariants and properties, --
    information about accessing basic features
  * Working with Ext -- information about functorial
    properties
  * Towards computing in the derived category

yonedaExtension'(Complex) -- identifies the element of Ext corresponding to an extension
****************************************************************************************

Synopsis
========

  * Function: yonedaExtension',
  * Usage:
        f = yonedaExtension' C
  * Inputs:
      * C, a complex, exact, of length $d$ over a ring $R$
  * Outputs:
      * f, a matrix (Macaulay2Doc), a map from $R^1$ to
        $\operatorname{Ext}^d(C_0, C_d)$

Description
===========

The module $\operatorname{Ext}^d(M,N)$ corresponds to equivalence classes of
extensions of $N$ by $M$.  In particular, an element of this module is
represented by an exact sequence of the form \[ 0 \leftarrow M \leftarrow C_1
\leftarrow C_2 \leftarrow \dots \leftarrow C_{d-1} \leftarrow N \leftarrow 0 \]
In particular, we have $M = C_0$ and $N = C_d$. For any such exact sequence,
this method returns the map $f \colon R^1 \to \operatorname{Ext}^d(M,N)$
corresponding to the element in the Ext module.

In our first example, the module $\operatorname{Ext}^1(M,R^1)$ has one
generator, in degree 0. The middle term in the corresponding short exact
sequence determines an irreducible rank 2 vector bundle on the elliptic curve.

+----------------------------------------------------------------------------+
|i1 : R = ZZ/101[x,y,z]/(y^2*z-x*(x-z)*(x-2*z));                             |
+----------------------------------------------------------------------------+
|i2 : M = truncate(1,R^1)                                                    |
|                                                                            |
|o2 = image | z y x |                                                        |
|                                                                            |
|                             1                                              |
|o2 : R-module, submodule of R                                               |
+----------------------------------------------------------------------------+
|i3 : N = R^1;                                                               |
+----------------------------------------------------------------------------+
|i4 : E = coker map(R^{3:-1} ++ R^1,,{                                       |
|             {y, x, 0, 0},                                                  |
|             {-z, 0, x, -y*z},                                              |
|             {0, -z, -y, x^2-3*x*z+2*z^2},                                  |
|             {x^2-3*x*z+2*z^2, y*z, 0, 0}                                   |
|             })                                                             |
|                                                                            |
|o4 = cokernel {1} | y          x  0  0          |                           |
|              {1} | -z         0  x  -yz        |                           |
|              {1} | 0          -z -y x2-3xz+2z2 |                           |
|              {0} | x2-3xz+2z2 yz 0  0          |                           |
|                                                                            |
|                            4                                               |
|o4 : R-module, quotient of R                                                |
+----------------------------------------------------------------------------+
|i5 : d1 = map(M, E, (cover E)^[0])                                          |
|                                                                            |
|o5 = {1} | 1 0 0 0 |                                                        |
|     {1} | 0 1 0 0 |                                                        |
|     {1} | 0 0 1 0 |                                                        |
|                                                                            |
|o5 : Matrix                                                                 |
+----------------------------------------------------------------------------+
|i6 : d2 = map(E, N, (cover E)_[1])                                          |
|                                                                            |
|o6 = {1} | 0 |                                                              |
|     {1} | 0 |                                                              |
|     {1} | 0 |                                                              |
|     {0} | 1 |                                                              |
|                                                                            |
|o6 : Matrix                                                                 |
+----------------------------------------------------------------------------+
|i7 : C = complex{d1,d2}                                                     |
|                                                                            |
|                                                                           1|
|o7 = image | z y x | <-- cokernel {1} | y          x  0  0          | <-- R |
|                                  {1} | -z         0  x  -yz        |       |
|     0                            {1} | 0          -z -y x2-3xz+2z2 |     2 |
|                                  {0} | x2-3xz+2z2 yz 0  0          |       |
|                                                                            |
|                         1                                                  |
|                                                                            |
|o7 : Complex                                                                |
+----------------------------------------------------------------------------+
|i8 : assert isWellDefined C                                                 |
+----------------------------------------------------------------------------+
|i9 : assert isHomogeneous C                                                 |
+----------------------------------------------------------------------------+
|i10 : assert(HH C == 0)                                                     |
+----------------------------------------------------------------------------+
|i11 : f = yonedaExtension' C                                                |
|                                                                            |
|o11 = {-1} | 0 |                                                            |
|      {-1} | 0 |                                                            |
|      {-1} | 0 |                                                            |
|      {0}  | 1 |                                                            |
|                                                                            |
|o11 : Matrix                                                                |
+----------------------------------------------------------------------------+

Although the complex representing $f$ is only defined up to equivalence of
extensions, this method returns the same complex in this example.

+---------------------------------------+
|i12 : assert(C == yonedaExtension f)   |
+---------------------------------------+
|i13 : assert(basis(0, Ext^1(M,N)) == f)|
+---------------------------------------+

The trivial extension corresponds to the zero element in the Ext module.

+-----------------------------------------------------------------------------+
|i14 : R = ZZ/101[a,b,c,d,e];                                                 |
+-----------------------------------------------------------------------------+
|i15 : M = coker matrix"a,b,d,e"                                              |
|                                                                             |
|o15 = cokernel | a b d e |                                                   |
|                                                                             |
|                             1                                               |
|o15 : R-module, quotient of R                                                |
+-----------------------------------------------------------------------------+
|i16 : N = coker matrix"c,d,e"                                                |
|                                                                             |
|o16 = cokernel | c d e |                                                     |
|                                                                             |
|                             1                                               |
|o16 : R-module, quotient of R                                                |
+-----------------------------------------------------------------------------+
|i17 : Ext^3(M,N)                                                             |
|                                                                             |
|o17 = subquotient ({-3} | 1 0 0 0 0 0 0 0 0 |, {-3} | 0 -b a 0  0 0 e d c 0 0|
|                   {-3} | 0 1 0 0 0 0 0 0 0 |  {-3} | 0 0  0 -b a 0 0 0 0 e d|
|                   {-3} | 0 0 e d c 0 0 0 a |  {-3} | 0 0  0 0  0 a 0 0 0 0 0|
|                   {-3} | 0 0 0 0 0 e d c b |  {-3} | 0 0  0 0  0 b 0 0 0 0 0|
|                                                                             |
|                                4                                            |
|o17 : R-module, subquotient of R                                             |
|-----------------------------------------------------------------------------|
|0 0 0 0 0 0 0 |)                                                             |
|c 0 0 0 0 0 0 |                                                              |
|0 e d c 0 0 0 |                                                              |
|0 0 0 0 e d c |                                                              |
+-----------------------------------------------------------------------------+
|i18 : C = complex{id_M, map(M, R^0, 0), map(R^0, N, 0), id_N}                |
|                                                                             |
|o18 = cokernel | a b d e | <-- cokernel | a b d e | <-- 0 <-- cokernel | c d |
|                                                                             |
|      0                        1                        2     3              |
|                                                                             |
|o18 : Complex                                                                |
|-----------------------------------------------------------------------------|
|e | <-- cokernel | c d e |                                                   |
|                                                                             |
|        4                                                                    |
+-----------------------------------------------------------------------------+
|i19 : assert isWellDefined C                                                 |
+-----------------------------------------------------------------------------+
|i20 : assert(HH C == 0)                                                      |
+-----------------------------------------------------------------------------+
|i21 : f = yonedaExtension' C                                                 |
|                                                                             |
|o21 = 0                                                                      |
|                                                                             |
|o21 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i22 : assert(target f === Ext^3(M,N))                                        |
+-----------------------------------------------------------------------------+
|i23 : assert(f == 0)                                                         |
+-----------------------------------------------------------------------------+
|i24 : D = yonedaExtension f                                                  |
|                                                                             |
|                                1      4                                     |
|o24 = cokernel | a b d e | <-- R  <-- R  <-- cokernel {2} | d  e  0  0  0 0 0|
|                                                      {2} | -b 0  e  0  0 0 0|
|      0                        1      2               {2} | a  0  0  e  0 0 0|
|                                                      {2} | 0  -b -d 0  0 0 0|
|                                                      {2} | 0  a  0  -d 0 0 0|
|                                                      {2} | 0  0  a  b  0 0 0|
|                                                      {0} | 0  0  0  0  c d e|
|                                                                             |
|                                             3                               |
|                                                                             |
|o24 : Complex                                                                |
|-----------------------------------------------------------------------------|
|| <-- cokernel | c d e |                                                     |
||                                                                            |
||     4                                                                      |
||                                                                            |
||                                                                            |
||                                                                            |
||                                                                            |
+-----------------------------------------------------------------------------+
|i25 : assert(C != D)                                                         |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Ext -- information about functorial
    properties
  * yonedaMap(Matrix) -- creates a chain complex
    map representing an extension of modules
  * yonedaMap'(ComplexMap) -- identifies the
    element of Ext corresponding to a map of free resolutions
  * yonedaExtension(Matrix) -- creates a
    chain complex representing an extension of modules
  * yonedaProduct(Module,Module), --
    make the product map between Ext modules

Ways to use this method:
========================

  * yonedaExtension'(Complex), --
    identifies the element of Ext corresponding to an extension

yonedaExtension(Matrix) -- creates a chain complex representing an extension of modules
***************************************************************************************

Synopsis
========

  * Function: yonedaExtension,
  * Usage:
        C = yonedaExtension f
  * Inputs:
      * f, a matrix (Macaulay2Doc), over a ring $R$, from $R^1$
        to $\operatorname{Ext}^d(M,N)$, which represents an element in the Ext
        module
  * Outputs:
      * C, a complex, which represents the extension
        corresponding to the element in the Ext module

Description
===========

The module $\operatorname{Ext}^d(M,N)$ corresponds to equivalence classes of
extensions of $N$ by $M$.  In particular, an element of this module is
represented by an exact sequence of the form \[ 0 \leftarrow M \leftarrow F_0
\leftarrow F_1 \leftarrow \dots \leftarrow F_{d-2} \leftarrow P \leftarrow N
\leftarrow 0 \] where $F_0 \leftarrow F_1 \leftarrow \dots$ is a free
resolution of $M$, and $P$ is the pushout of the maps $g : F_d \rightarrow N$
and $F_d \rightarrow F_{d-1}$. The element corresponding to $f$ in
$\operatorname{Ext}^d(M,N)$ lifts to the map $g$.

In our first example, the module $\operatorname{Ext}^1(M,R^1)$ has one
generator, in degree 0. The middle term in the corresponding short exact
sequence determines an irreducible rank 2 vector bundle on the elliptic curve,
which can be verified by computing Fitting ideals.

+----------------------------------------------------------------------------+
|i1 : R = ZZ/101[x,y,z]/(y^2*z-x*(x-z)*(x-2*z));                             |
+----------------------------------------------------------------------------+
|i2 : M = truncate(1,R^1)                                                    |
|                                                                            |
|o2 = image | z y x |                                                        |
|                                                                            |
|                             1                                              |
|o2 : R-module, submodule of R                                               |
+----------------------------------------------------------------------------+
|i3 : f = basis(0, Ext^1(M, R^1))                                            |
|                                                                            |
|o3 = {-1} | 0 |                                                             |
|     {-1} | 0 |                                                             |
|     {-1} | 0 |                                                             |
|     {0}  | 1 |                                                             |
|                                                                            |
|o3 : Matrix                                                                 |
+----------------------------------------------------------------------------+
|i4 : C = yonedaExtension f                                                  |
|                                                                            |
|                                                                           1|
|o4 = image | z y x | <-- cokernel {1} | y          x  0  0          | <-- R |
|                                  {1} | -z         0  x  -yz        |       |
|     0                            {1} | 0          -z -y x2-3xz+2z2 |     2 |
|                                  {0} | x2-3xz+2z2 yz 0  0          |       |
|                                                                            |
|                         1                                                  |
|                                                                            |
|o4 : Complex                                                                |
+----------------------------------------------------------------------------+
|i5 : assert isWellDefined C                                                 |
+----------------------------------------------------------------------------+
|i6 : assert isShortExactSequence(dd^C_1, dd^C_2)                            |
+----------------------------------------------------------------------------+
|i7 : E = C_1                                                                |
|                                                                            |
|o7 = cokernel {1} | y          x  0  0          |                           |
|              {1} | -z         0  x  -yz        |                           |
|              {1} | 0          -z -y x2-3xz+2z2 |                           |
|              {0} | x2-3xz+2z2 yz 0  0          |                           |
|                                                                            |
|                            4                                               |
|o7 : R-module, quotient of R                                                |
+----------------------------------------------------------------------------+
|i8 : fittingIdeal(1, E)                                                     |
|                                                                            |
|o8 = ideal ()                                                               |
|                                                                            |
|o8 : Ideal of R                                                             |
+----------------------------------------------------------------------------+
|i9 : saturate fittingIdeal(2, E)                                            |
|                                                                            |
|o9 = ideal 1                                                                |
|                                                                            |
|o9 : Ideal of R                                                             |
+----------------------------------------------------------------------------+

For higher Ext modules, we get longer exact sequences. When the map $f$ has
degree 0, the corresponding exact sequence is homogeneous.

+-----------------------------------------------------------------------------+
|i10 : x = symbol x;                                                          |
+-----------------------------------------------------------------------------+
|i11 : S = ZZ/101[x_0..x_5];                                                  |
+-----------------------------------------------------------------------------+
|i12 : I = borel monomialIdeal(x_2*x_3)                                       |
|                                                                             |
|                      2         2               2                            |
|o12 = monomialIdeal (x , x x , x , x x , x x , x , x x , x x , x x )         |
|                      0   0 1   1   0 2   1 2   2   0 3   1 3   2 3          |
|                                                                             |
|o12 : MonomialIdeal of S                                                     |
+-----------------------------------------------------------------------------+
|i13 : E = Ext^4(S^1/I, S^{-5})                                               |
|                                                                             |
|o13 = cokernel | -x_3 0    0    x_2 0   -x_1 x_0  0    0   0   0    0   |    |
|               | 0    -x_3 0    0   x_2 0    0    -x_1 0   x_0 0    0   |    |
|               | 0    0    -x_3 0   0   0    -x_2 x_2  x_2 0   -x_1 x_0 |    |
|                                                                             |
|                             3                                               |
|o13 : S-module, quotient of S                                                |
+-----------------------------------------------------------------------------+
|i14 : f = E_{0}                                                              |
|                                                                             |
|o14 = | 1 |                                                                  |
|      | 0 |                                                                  |
|      | 0 |                                                                  |
|                                                                             |
|o14 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i15 : assert(isHomogeneous f and degree f === {0})                           |
+-----------------------------------------------------------------------------+
|i16 : C = yonedaExtension f                                                  |
|                                                                             |
|                                                                             |
|o16 = cokernel | x_0^2 x_0x_1 x_1^2 x_0x_2 x_1x_2 x_2^2 x_0x_3 x_1x_3 x_2x_3 |
|                                                                             |
|      0                                                                      |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|o16 : Complex                                                                |
|-----------------------------------------------------------------------------|
|       1      9      17                                          1           |
|| <-- S  <-- S  <-- S   <-- cokernel {4} | -x_3 0    0    | <-- S            |
|                                     {4} | 0    -x_3 0    |                  |
|      1      2      3                {4} | 0    0    -x_3 |     5            |
|                                     {4} | x_2  0    0    |                  |
|                                     {4} | 0    x_2  0    |                  |
|                                     {4} | -x_1 0    0    |                  |
|                                     {4} | x_0  0    -x_2 |                  |
|                                     {4} | 0    -x_1 x_2  |                  |
|                                     {4} | 0    0    x_2  |                  |
|                                     {4} | 0    x_0  0    |                  |
|                                     {4} | 0    0    -x_1 |                  |
|                                     {4} | 0    0    x_0  |                  |
|                                     {5} | 1    0    0    |                  |
|                                                                             |
|                            4                                                |
+-----------------------------------------------------------------------------+
|i17 : assert isWellDefined C                                                 |
+-----------------------------------------------------------------------------+
|i18 : assert isHomogeneous C                                                 |
+-----------------------------------------------------------------------------+
|i19 : assert(HH C == 0)                                                      |
+-----------------------------------------------------------------------------+

The inverse operation is given by yonedaExtension'.

+-----------------------------+
|i20 : f' = yonedaExtension' C|
|                             |
|o20 = | 1 |                  |
|      | 0 |                  |
|      | 0 |                  |
|                             |
|o20 : Matrix                 |
+-----------------------------+
|i21 : assert(f' == f)        |
+-----------------------------+

See also
========

  * Working with Ext -- information about functorial
    properties
  * yonedaMap(Matrix) -- creates a chain complex
    map representing an extension of modules
  * yonedaMap'(ComplexMap) -- identifies the
    element of Ext corresponding to a map of free resolutions
  * yonedaExtension'(Complex), --
    identifies the element of Ext corresponding to an extension
  * yonedaProduct(Module,Module), --
    make the product map between Ext modules
  * homomorphism(ComplexMap) -- get the
    homomorphism from an element of Hom
  * homomorphism'(ComplexMap) -- get the
    element of Hom from a map of complexes
  * fittingIdeal (Macaulay2Doc) -- Fitting ideal of a
    module

Ways to use this method:
========================

  * yonedaExtension(Matrix) -- creates a
    chain complex representing an extension of modules

yonedaMap'(ComplexMap) -- identifies the element of Ext corresponding to a map of free resolutions
**************************************************************************************************

Synopsis
========

  * Function: yonedaMap',
  * Usage:
        f = yonedaMap' g
  * Inputs:
      * g, a map of complexes, of degree $-d$ from the free
        resolution of $M$ to the free resolution of $N$
  * Optional inputs (Macaulay2Doc),:
      * LengthLimit => an integer (Macaulay2Doc), default value
        infinity, an upper bound on the lengths of the free resolutions
        constructed
  * Outputs:
      * f, a matrix (Macaulay2Doc), over a ring $R$, from $R^1$
        to $\operatorname{Ext}^d_R(M,N)$, which represents the corresponding
        element in the Ext module

Description
===========

The module $\operatorname{Ext}^d_R(M,N)$ is constructed from a free resolution
$F$ of $M$, \[ 0 \leftarrow M \leftarrow F_0 \leftarrow F_1 \leftarrow \dots
\leftarrow F_d \leftarrow \ldots, \] by taking the homology of the complex
$\operatorname{Hom}_R(F, N)$. An element of $\operatorname{Ext}^d_R(M,N)$ is
represented by an element of $\operatorname{Hom}_R(F_d, N)$.  Given a map $g$
extending a map of degree $-d$ from $F$ to the free resolution of $N$, this
method returns the corresponding element in the Ext module.

We illustrate this method by choosing a random element in an Ext module,
constructing the corresponding map  $g$ between free resolutions.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..d]                                                        |
|                                                                             |
|o1 = S                                                                       |
|                                                                             |
|o1 : PolynomialRing                                                          |
+-----------------------------------------------------------------------------+
|i2 : I = ideal"a2,ab,ac,b3"                                                  |
|                                                                             |
|             2             3                                                 |
|o2 = ideal (a , a*b, a*c, b )                                                |
|                                                                             |
|o2 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i3 : E = Ext^1(I, S^1/I)                                                     |
|                                                                             |
|o3 = subquotient ({-3} | 0 a b 0 0 0 0 0  |, {-3} | -b a  0 0  0  0  0  ac ab|
|                  {-3} | 0 0 c a 0 0 0 b2 |  {-3} | -c 0  a 0  0  0  0  0  0 |
|                  {-3} | 0 0 0 0 c b a 0  |  {-3} | 0  -c b 0  0  0  0  0  0 |
|                  {-4} | 1 0 0 0 0 0 0 0  |  {-4} | 0  b2 0 -a ac ab a2 0  0 |
|                                                                             |
|                               4                                             |
|o3 : S-module, subquotient of S                                              |
|-----------------------------------------------------------------------------|
|a2 0  0  0  0  0  0  0  b3 0  0  |)                                          |
|0  ac ab a2 0  0  0  0  0  b3 0  |                                           |
|0  0  0  0  ac ab a2 0  0  0  b3 |                                           |
|0  0  0  0  0  0  0  b3 0  0  0  |                                           |
+-----------------------------------------------------------------------------+
|i4 : B = basis(0, E)                                                         |
|                                                                             |
|o4 = {-4} | bc3 bc2d bcd2 bd3 c4 c3d c2d2 cd3 d4 0  0  0  0  0  0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  d2 0  0  0  0  0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  0  0  0  0  0  0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  0  d2 0  0  0  0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  0  0  c2 cd d2 0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  0  0  0  0  0  0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  0  0  0  0  0  d2 0 |       |
|     {-1} | 0   0    0    0   0  0   0    0   0  0  0  0  0  0  0  d |       |
|                                                                             |
|o4 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i5 : f0 = B * random(S^16, S^1)                                              |
|                                                                             |
|o5 = {-4} | 24bc3+19c4-36bc2d+19c3d-30bcd2-10c2d2-29bd3-29cd3-8d4 |          |
|     {-2} | -22d2                                                 |          |
|     {-2} | 0                                                     |          |
|     {-2} | -29d2                                                 |          |
|     {-2} | -24c2-38cd-16d2                                       |          |
|     {-2} | 0                                                     |          |
|     {-2} | 39d2                                                  |          |
|     {-1} | 21d                                                   |          |
|                                                                             |
|o5 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i6 : g = yonedaMap f0                                                        |
|                                                                             |
|          1                                                                  |
|o6 = 0 : S  <----------------------------------------------------------------|
|               | -22ad2 21b2d-29ad2 -24c3-38c2d+39ad2-16cd2 24bc3+19c4-36bc2d|
|                                                                             |
|          4                              1                                   |
|     1 : S  <-------------------------- S  : 2                               |
|               {2} | -39d2          |                                        |
|               {2} | -29d2          |                                        |
|               {2} | 24c2+38cd+38d2 |                                        |
|               {3} | 21d            |                                        |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                          4                                  |
|---------------------------------------- S  : 1                              |
|+19c3d-30bcd2-10c2d2-29bd3-29cd3-8d4 |                                       |
+-----------------------------------------------------------------------------+
|i7 : assert(degree g === -1)                                                 |
+-----------------------------------------------------------------------------+
|i8 : f = yonedaMap' g                                                        |
|                                                                             |
|o8 = {-4} | 24bc3+19c4-36bc2d+19c3d-30bcd2-10c2d2-29bd3-29cd3-8d4 |          |
|     {-2} | -22d2                                                 |          |
|     {-2} | 0                                                     |          |
|     {-2} | -29d2                                                 |          |
|     {-2} | -24c2-38cd-16d2                                       |          |
|     {-2} | 0                                                     |          |
|     {-2} | 39d2                                                  |          |
|     {-1} | 21d                                                   |          |
|                                                                             |
|o8 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i9 : assert isWellDefined f                                                  |
+-----------------------------------------------------------------------------+
|i10 : assert(degree f == {0})                                                |
+-----------------------------------------------------------------------------+
|i11 : assert isHomogeneous f                                                 |
+-----------------------------------------------------------------------------+
|i12 : source f === S^1                                                       |
|                                                                             |
|o12 = true                                                                   |
+-----------------------------------------------------------------------------+
|i13 : target f === E                                                         |
|                                                                             |
|o13 = true                                                                   |
+-----------------------------------------------------------------------------+
|i14 : assert(f == f0)                                                        |
+-----------------------------------------------------------------------------+

The method yonedaMap', is only a one-sided
inverse to yonedaMap.

+--------------------------------------------------------+
|i15 : R = ZZ/101[x,y,z]/(y^2*z-x*(x-z)*(x-2*z));        |
+--------------------------------------------------------+
|i16 : M = truncate(1,R^1)                               |
|                                                        |
|o16 = image | z y x |                                   |
|                                                        |
|                              1                         |
|o16 : R-module, submodule of R                          |
+--------------------------------------------------------+
|i17 : B = basis(-4, Ext^3(M, M))                        |
|                                                        |
|o17 = {-4} | 0 0 0 |                                    |
|      {-4} | 1 0 0 |                                    |
|      {-4} | 0 1 0 |                                    |
|      {-4} | 0 0 0 |                                    |
|      {-4} | 0 0 1 |                                    |
|      {-4} | 0 0 0 |                                    |
|      {-3} | 0 0 0 |                                    |
|      {-3} | 0 0 0 |                                    |
|      {-3} | 0 0 0 |                                    |
|      {-3} | 0 0 0 |                                    |
|      {-3} | 0 0 0 |                                    |
|      {-3} | 0 0 0 |                                    |
|      {-3} | 0 0 0 |                                    |
|      {-3} | 0 0 0 |                                    |
|      {-3} | 0 0 0 |                                    |
|      {-3} | 0 0 0 |                                    |
|                                                        |
|o17 : Matrix                                            |
+--------------------------------------------------------+
|i18 : f0 = B_{2}                                        |
|                                                        |
|o18 = {-4} | 0 |                                        |
|      {-4} | 0 |                                        |
|      {-4} | 0 |                                        |
|      {-4} | 0 |                                        |
|      {-4} | 1 |                                        |
|      {-4} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|                                                        |
|o18 : Matrix                                            |
+--------------------------------------------------------+
|i19 : g = yonedaMap(f0, LengthLimit => 8)               |
|                                                        |
|           3                             4              |
|o19 = 0 : R  <------------------------- R  : 3          |
|                {1} | -49 0   0   0 |                   |
|                {1} | 0   -49 -50 0 |                   |
|                {1} | 50  0   0   z |                   |
|                                                        |
|           4                                       4    |
|      1 : R  <----------------------------------- R  : 4|
|                {2} | 49 0    -46x-3z 0       |         |
|                {2} | 0  -49x 0       -46x-3z |         |
|                {2} | 50 0    -49x    0       |         |
|                {3} | 0  50   0       49      |         |
|                                                        |
|           4                                   4        |
|      2 : R  <------------------------------- R  : 5    |
|                {3} | 0   -46x-3z -49x yz |             |
|                {4} | -49 0       0    x  |             |
|                {4} | 0   -49     -50  0  |             |
|                {4} | 50  0       0    0  |             |
|                                                        |
|           4                                 4          |
|      3 : R  <----------------------------- R  : 6      |
|                {5} | 0   0  0       x  |               |
|                {5} | -50 0  49x+z   0  |               |
|                {5} | 49  0  -47x-3z 0  |               |
|                {6} | 0   50 0       49 |               |
|                                                        |
|           4                                    4       |
|      4 : R  <-------------------------------- R  : 7   |
|                {6} | 0   -47x-3z -49x-z 0 |            |
|                {7} | -49 0       0      x |            |
|                {7} | 0   -49     -50    0 |            |
|                {7} | 50  0       0      0 |            |
|                                                        |
|           4                                 4          |
|      5 : R  <----------------------------- R  : 8      |
|                {8} | 0   0  0       x  |               |
|                {8} | -50 0  49x+z   0  |               |
|                {8} | 49  0  -47x-3z 0  |               |
|                {9} | 0   50 0       49 |               |
|                                                        |
|o19 : ComplexMap                                        |
+--------------------------------------------------------+
|i20 : f = yonedaMap' g                                  |
|                                                        |
|o20 = {-4} | 0 |                                        |
|      {-4} | 0 |                                        |
|      {-4} | 0 |                                        |
|      {-4} | 0 |                                        |
|      {-4} | 1 |                                        |
|      {-4} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|      {-3} | 0 |                                        |
|                                                        |
|o20 : Matrix                                            |
+--------------------------------------------------------+
|i21 : assert isWellDefined f                            |
+--------------------------------------------------------+
|i22 : assert isHomogeneous f                            |
+--------------------------------------------------------+
|i23 : assert(degree f === {-4})                         |
+--------------------------------------------------------+
|i24 : assert(f != f0)                                   |
+--------------------------------------------------------+
|i25 : assert(yonedaMap(f, LengthLimit => 8) == g)       |
+--------------------------------------------------------+

See also
========

  * Working with Ext -- information about functorial
    properties
  * yonedaMap(Matrix) -- creates a chain complex
    map representing an extension of modules
  * yonedaExtension(Matrix) -- creates a
    chain complex representing an extension of modules
  * yonedaExtension'(Complex), --
    identifies the element of Ext corresponding to an extension
  * yonedaProduct(Matrix,Matrix), --
    make the product of two elements in Ext modules
  * yonedaProduct(Module,Module), --
    make the product map between Ext modules

Ways to use this method:
========================

  * yonedaMap'(ComplexMap) -- identifies the
    element of Ext corresponding to a map of free resolutions

yonedaMap(Matrix) -- creates a chain complex map representing an extension of modules
*************************************************************************************

Synopsis
========

  * Function: yonedaMap,
  * Usage:
        g = yonedaMap f
  * Inputs:
      * f, a matrix (Macaulay2Doc), over a ring $R$, from $R^1$
        to $\operatorname{Ext}^d_R(M,N)$, which represents an element in the
        Ext module
  * Optional inputs (Macaulay2Doc),:
      * LengthLimit => an integer (Macaulay2Doc), default value
        infinity, determines the maximum length of the free resolutions used
  * Outputs:
      * g, a map of complexes, of degree $-d$ from the free
        resolution of $M$ to the free resolution of $N$ corresponding to the
        given element in the Ext module

Description
===========

The module $\operatorname{Ext}^d_R(M,N)$ is constructed from a free resolution
$F$ of $M$, \[ 0 \leftarrow M \leftarrow F_0 \leftarrow F_1 \leftarrow \dots
\leftarrow F_d \leftarrow \ldots, \] by taking the homology of the complex
$\operatorname{Hom}_R(F, N)$. An element of $\operatorname{Ext}^d_R(M,N)$ is
represented by an element of $\operatorname{Hom}_R(F_d, N)$.  This map extends
to a map of degree $-d$ from $F$ to the free resolution of $N$.

We illustrate this method by choosing a random element in an Ext module.  This
particular Ext module may be regarded as a possible obstruction space for
deformations of the ideal $I$.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[a..d]                                                        |
|                                                                             |
|o1 = S                                                                       |
|                                                                             |
|o1 : PolynomialRing                                                          |
+-----------------------------------------------------------------------------+
|i2 : I = ideal"a2,ab,ac,b3"                                                  |
|                                                                             |
|             2             3                                                 |
|o2 = ideal (a , a*b, a*c, b )                                                |
|                                                                             |
|o2 : Ideal of S                                                              |
+-----------------------------------------------------------------------------+
|i3 : E = Ext^1(I, S^1/I)                                                     |
|                                                                             |
|o3 = subquotient ({-3} | 0 a b 0 0 0 0 0  |, {-3} | -b a  0 0  0  0  0  ac ab|
|                  {-3} | 0 0 c a 0 0 0 b2 |  {-3} | -c 0  a 0  0  0  0  0  0 |
|                  {-3} | 0 0 0 0 c b a 0  |  {-3} | 0  -c b 0  0  0  0  0  0 |
|                  {-4} | 1 0 0 0 0 0 0 0  |  {-4} | 0  b2 0 -a ac ab a2 0  0 |
|                                                                             |
|                               4                                             |
|o3 : S-module, subquotient of S                                              |
|-----------------------------------------------------------------------------|
|a2 0  0  0  0  0  0  0  b3 0  0  |)                                          |
|0  ac ab a2 0  0  0  0  0  b3 0  |                                           |
|0  0  0  0  ac ab a2 0  0  0  b3 |                                           |
|0  0  0  0  0  0  0  b3 0  0  0  |                                           |
+-----------------------------------------------------------------------------+
|i4 : B = basis(0, E)                                                         |
|                                                                             |
|o4 = {-4} | bc3 bc2d bcd2 bd3 c4 c3d c2d2 cd3 d4 0  0  0  0  0  0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  d2 0  0  0  0  0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  0  0  0  0  0  0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  0  d2 0  0  0  0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  0  0  c2 cd d2 0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  0  0  0  0  0  0  0 |       |
|     {-2} | 0   0    0    0   0  0   0    0   0  0  0  0  0  0  d2 0 |       |
|     {-1} | 0   0    0    0   0  0   0    0   0  0  0  0  0  0  0  d |       |
|                                                                             |
|o4 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i5 : f = B * random(S^16, S^1)                                               |
|                                                                             |
|o5 = {-4} | 24bc3+19c4-36bc2d+19c3d-30bcd2-10c2d2-29bd3-29cd3-8d4 |          |
|     {-2} | -22d2                                                 |          |
|     {-2} | 0                                                     |          |
|     {-2} | -29d2                                                 |          |
|     {-2} | -24c2-38cd-16d2                                       |          |
|     {-2} | 0                                                     |          |
|     {-2} | 39d2                                                  |          |
|     {-1} | 21d                                                   |          |
|                                                                             |
|o5 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i6 : g = yonedaMap f                                                         |
|                                                                             |
|          1                                                                  |
|o6 = 0 : S  <----------------------------------------------------------------|
|               | -22ad2 21b2d-29ad2 -24c3-38c2d+39ad2-16cd2 24bc3+19c4-36bc2d|
|                                                                             |
|          4                              1                                   |
|     1 : S  <-------------------------- S  : 2                               |
|               {2} | -39d2          |                                        |
|               {2} | -29d2          |                                        |
|               {2} | 24c2+38cd+38d2 |                                        |
|               {3} | 21d            |                                        |
|                                                                             |
|o6 : ComplexMap                                                              |
|-----------------------------------------------------------------------------|
|                                          4                                  |
|---------------------------------------- S  : 1                              |
|+19c3d-30bcd2-10c2d2-29bd3-29cd3-8d4 |                                       |
+-----------------------------------------------------------------------------+
|i7 : assert isWellDefined g                                                  |
+-----------------------------------------------------------------------------+
|i8 : assert(degree g === -1)                                                 |
+-----------------------------------------------------------------------------+
|i9 : assert isCommutative g                                                  |
+-----------------------------------------------------------------------------+
|i10 : assert isHomogeneous g                                                 |
+-----------------------------------------------------------------------------+
|i11 : source g -- free resolution of I                                       |
|                                                                             |
|       4      4      1                                                       |
|o11 = S  <-- S  <-- S                                                        |
|                                                                             |
|      0      1      2                                                        |
|                                                                             |
|o11 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i12 : target g -- free resolution of S/I                                     |
|                                                                             |
|       1      4      4      1                                                |
|o12 = S  <-- S  <-- S  <-- S                                                 |
|                                                                             |
|      0      1      2      3                                                 |
|                                                                             |
|o12 : Complex                                                                |
+-----------------------------------------------------------------------------+
|i13 : assert(yonedaMap' g == f)                                              |
+-----------------------------------------------------------------------------+

If the free resolutions are not finite in length, one needs to choose a
truncation via the optional argument LengthLimit.

+-----------------------------------------------------------------+
|i14 : R = ZZ/101[x,y,z]/(y^2*z-x*(x-z)*(x-2*z));                 |
+-----------------------------------------------------------------+
|i15 : M = truncate(1,R^1)                                        |
|                                                                 |
|o15 = image | z y x |                                            |
|                                                                 |
|                              1                                  |
|o15 : R-module, submodule of R                                   |
+-----------------------------------------------------------------+
|i16 : prune Ext^3(M, M)                                          |
|                                                                 |
|o16 = cokernel {-4} | z y x 0 0 0 0 0 0 0 0 0 |                  |
|               {-4} | 0 0 0 z y x 0 0 0 0 0 0 |                  |
|               {-4} | 0 0 0 0 0 0 z y x 0 0 0 |                  |
|               {-3} | 0 0 0 0 0 0 0 0 0 z y x |                  |
|                                                                 |
|                             4                                   |
|o16 : R-module, quotient of R                                    |
+-----------------------------------------------------------------+
|i17 : B = basis(-4, Ext^3(M, M))                                 |
|                                                                 |
|o17 = {-4} | 0 0 0 |                                             |
|      {-4} | 1 0 0 |                                             |
|      {-4} | 0 1 0 |                                             |
|      {-4} | 0 0 0 |                                             |
|      {-4} | 0 0 1 |                                             |
|      {-4} | 0 0 0 |                                             |
|      {-3} | 0 0 0 |                                             |
|      {-3} | 0 0 0 |                                             |
|      {-3} | 0 0 0 |                                             |
|      {-3} | 0 0 0 |                                             |
|      {-3} | 0 0 0 |                                             |
|      {-3} | 0 0 0 |                                             |
|      {-3} | 0 0 0 |                                             |
|      {-3} | 0 0 0 |                                             |
|      {-3} | 0 0 0 |                                             |
|      {-3} | 0 0 0 |                                             |
|                                                                 |
|o17 : Matrix                                                     |
+-----------------------------------------------------------------+
|i18 : f = B_{2}                                                  |
|                                                                 |
|o18 = {-4} | 0 |                                                 |
|      {-4} | 0 |                                                 |
|      {-4} | 0 |                                                 |
|      {-4} | 0 |                                                 |
|      {-4} | 1 |                                                 |
|      {-4} | 0 |                                                 |
|      {-3} | 0 |                                                 |
|      {-3} | 0 |                                                 |
|      {-3} | 0 |                                                 |
|      {-3} | 0 |                                                 |
|      {-3} | 0 |                                                 |
|      {-3} | 0 |                                                 |
|      {-3} | 0 |                                                 |
|      {-3} | 0 |                                                 |
|      {-3} | 0 |                                                 |
|      {-3} | 0 |                                                 |
|                                                                 |
|o18 : Matrix                                                     |
+-----------------------------------------------------------------+
|i19 : g = yonedaMap(f, LengthLimit => 8)                         |
|                                                                 |
|           3                             4                       |
|o19 = 0 : R  <------------------------- R  : 3                   |
|                {1} | -49 0   0   0 |                            |
|                {1} | 0   -49 -50 0 |                            |
|                {1} | 50  0   0   z |                            |
|                                                                 |
|           4                                       4             |
|      1 : R  <----------------------------------- R  : 4         |
|                {2} | 49 0    -46x-3z 0       |                  |
|                {2} | 0  -49x 0       -46x-3z |                  |
|                {2} | 50 0    -49x    0       |                  |
|                {3} | 0  50   0       49      |                  |
|                                                                 |
|           4                                   4                 |
|      2 : R  <------------------------------- R  : 5             |
|                {3} | 0   -46x-3z -49x yz |                      |
|                {4} | -49 0       0    x  |                      |
|                {4} | 0   -49     -50  0  |                      |
|                {4} | 50  0       0    0  |                      |
|                                                                 |
|           4                                 4                   |
|      3 : R  <----------------------------- R  : 6               |
|                {5} | 0   0  0       x  |                        |
|                {5} | -50 0  49x+z   0  |                        |
|                {5} | 49  0  -47x-3z 0  |                        |
|                {6} | 0   50 0       49 |                        |
|                                                                 |
|           4                                    4                |
|      4 : R  <-------------------------------- R  : 7            |
|                {6} | 0   -47x-3z -49x-z 0 |                     |
|                {7} | -49 0       0      x |                     |
|                {7} | 0   -49     -50    0 |                     |
|                {7} | 50  0       0      0 |                     |
|                                                                 |
|           4                                 4                   |
|      5 : R  <----------------------------- R  : 8               |
|                {8} | 0   0  0       x  |                        |
|                {8} | -50 0  49x+z   0  |                        |
|                {8} | 49  0  -47x-3z 0  |                        |
|                {9} | 0   50 0       49 |                        |
|                                                                 |
|o19 : ComplexMap                                                 |
+-----------------------------------------------------------------+
|i20 : assert isHomogeneous g                                     |
+-----------------------------------------------------------------+
|i21 : assert isWellDefined g                                     |
+-----------------------------------------------------------------+
|i22 : assert isCommutative g                                     |
+-----------------------------------------------------------------+
|i23 : assert(degree g === -3)                                    |
+-----------------------------------------------------------------+
|i24 : assert(yonedaMap' g == map(target f, R^1, f, Degree => -4))|
+-----------------------------------------------------------------+
|i25 : assert(isHomogeneous yonedaMap' g)                         |
+-----------------------------------------------------------------+

See also
========

  * Working with Ext -- information about functorial
    properties
  * yonedaMap'(ComplexMap) -- identifies the
    element of Ext corresponding to a map of free resolutions
  * yonedaExtension(Matrix) -- creates a
    chain complex representing an extension of modules
  * yonedaExtension'(Complex), --
    identifies the element of Ext corresponding to an extension
  * yonedaProduct(Matrix,Matrix), --
    make the product of two elements in Ext modules
  * yonedaProduct(Module,Module), --
    make the product map between Ext modules

Ways to use this method:
========================

  * yonedaMap(Matrix) -- creates a chain complex
    map representing an extension of modules

yonedaProduct(Matrix,Matrix) -- make the product of two elements in Ext modules
*******************************************************************************

Synopsis
========

  * Function: yonedaProduct,
  * Usage:
        h = yonedaProduct(f,g)
  * Inputs:
      * f, a matrix (Macaulay2Doc), of the form $f \colon R \to
        \operatorname{Ext}_R^d(L,M)$
      * g, a matrix (Macaulay2Doc), of the form $g \colon R \to
        \operatorname{Ext}_R^e(M,N)$
  * Outputs:
      * h, a matrix (Macaulay2Doc), of the form $h \colon R \to
        \operatorname{Ext}_R^{d+e}(L,N)$

Description
===========

Given a triple $(L, M, N)$ of $R$-modules, the Yoneda product is a pairing
between $\operatorname{Ext}$-modules

$\phantom{WWWW} \operatorname{Ext}_R^d(L,M) \otimes \operatorname{Ext}_R^e(M,N)
\to \operatorname{Ext}_R^{d+e}(L,N). $

For an element of $\operatorname{Ext}_R^{e}(M,N)$, thought of as an extension

$\phantom{WWWW} 0 \leftarrow M \leftarrow F_{0} \leftarrow F_{1} \leftarrow
\dotsb \leftarrow F_{e-2} \leftarrow P \leftarrow N \leftarrow 0, $

and for an element of $\operatorname{Ext}_R^{d}(L,M)$, thought of as an
extension

$\phantom{WWWW} 0 \leftarrow L \leftarrow G_{0} \leftarrow G_1 \leftarrow
\dotsb \leftarrow G_{d-2} \leftarrow Q \leftarrow M \leftarrow 0, $

the Yoneda product corresponds to

$\phantom{WWWW} 0 \leftarrow L \leftarrow G_{0} \leftarrow G_{1} \leftarrow
\dotsb \leftarrow Q \leftarrow F_{0} \leftarrow F_{1} \leftarrow \dotsb
\leftarrow P \leftarrow N \leftarrow 0, $

where the map from $F_0$ to $Q$ factors through $M$.  For more information
about extensions, see yonedaExtension.

Alternatively, the module $\operatorname{Ext}^d_R(L,M)$ is constructed from a
free resolution $G$ of $L$,

$\phantom{WWWW} 0 \leftarrow L \leftarrow G_0 \leftarrow G_1 \leftarrow \dotsb
\leftarrow G_d \leftarrow \dotsb, $

by taking the homology of the complex $\operatorname{Hom}_R(G, M)$. An element
of $\operatorname{Ext}^d_R(L,M)$ is represented by an element of
$\operatorname{Hom}_R(G_d, M)$.  This map extends to a complex map having
degree $-d$ from $G$ to the free resolution $F$ of $M$. The Yoneda product is
the composition of the map of chain complexes from $G$ to $F$ with the map of
chain complexes having degree $-e$ from $F$ to a free resolution of $N$. For
more information about these maps, see yonedaMap.

As an example, we take two distinct elements of an
$\operatorname{Ext}^1$-module to obtain a non-zero element of the
$\operatorname{Ext}^2$-module.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[x_0..x_3];                                                   |
+-----------------------------------------------------------------------------+
|i2 : I = borel monomialIdeal(x_1*x_2)                                        |
|                                                                             |
|                     2         2                                             |
|o2 = monomialIdeal (x , x x , x , x x , x x )                                |
|                     0   0 1   1   0 2   1 2                                 |
|                                                                             |
|o2 : MonomialIdeal of S                                                      |
+-----------------------------------------------------------------------------+
|i3 : E1 = Ext^1(S^1/I, S^1/I)                                                |
|                                                                             |
|o3 = subquotient ({-2} | x_1 x_0 0   0   0   0   0   0   0   0   0   0   |,  |
|                  {-2} | 0   0   x_1 x_0 0   0   0   0   0   0   0   0   |   |
|                  {-2} | 0   0   0   0   x_1 x_0 0   0   0   0   0   0   |   |
|                  {-2} | 0   0   0   0   0   0   x_2 x_1 x_0 0   0   0   |   |
|                  {-2} | 0   0   0   0   0   0   0   0   0   x_2 x_1 x_0 |   |
|                                                                             |
|                               5                                             |
|o3 : S-module, subquotient of S                                              |
|-----------------------------------------------------------------------------|
|{-2} | 0 x_1x_2 x_0x_2 x_1^2 x_0x_1 x_0^2 0      0      0     0      0       |
|{-2} | 0 0      0      0     0      0     x_1x_2 x_0x_2 x_1^2 x_0x_1 x_0^2   |
|{-2} | 0 0      0      0     0      0     0      0      0     0      0       |
|{-2} | 0 0      0      0     0      0     0      0      0     0      0       |
|{-2} | 0 0      0      0     0      0     0      0      0     0      0       |
|-----------------------------------------------------------------------------|
|0      0      0     0      0     0      0      0     0      0     0          |
|0      0      0     0      0     0      0      0     0      0     0          |
|x_1x_2 x_0x_2 x_1^2 x_0x_1 x_0^2 0      0      0     0      0     0          |
|0      0      0     0      0     x_1x_2 x_0x_2 x_1^2 x_0x_1 x_0^2 0          |
|0      0      0     0      0     0      0      0     0      0     x_1x_2     |
|-----------------------------------------------------------------------------|
|0      0     0      0     |)                                                 |
|0      0     0      0     |                                                  |
|0      0     0      0     |                                                  |
|0      0     0      0     |                                                  |
|x_0x_2 x_1^2 x_0x_1 x_0^2 |                                                  |
+-----------------------------------------------------------------------------+
|i4 : (f, g) = (E1_{6}, E1_{9})                                               |
|                                                                             |
|o4 = ({-1} | 0 |, {-1} | 0 |)                                                |
|      {-1} | 0 |  {-1} | 0 |                                                 |
|      {-1} | 0 |  {-1} | 0 |                                                 |
|      {-1} | 0 |  {-1} | 0 |                                                 |
|      {-1} | 0 |  {-1} | 0 |                                                 |
|      {-1} | 0 |  {-1} | 0 |                                                 |
|      {-1} | 1 |  {-1} | 0 |                                                 |
|      {-1} | 0 |  {-1} | 0 |                                                 |
|      {-1} | 0 |  {-1} | 0 |                                                 |
|      {-1} | 0 |  {-1} | 1 |                                                 |
|      {-1} | 0 |  {-1} | 0 |                                                 |
|      {-1} | 0 |  {-1} | 0 |                                                 |
|                                                                             |
|o4 : Sequence                                                                |
+-----------------------------------------------------------------------------+
|i5 : h = yonedaProduct(f, g)                                                 |
|                                                                             |
|o5 = {-2} | 0  |                                                             |
|     {-2} | -1 |                                                             |
|     {-2} | 1  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 1  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 0  |                                                             |
|     {-2} | 0  |                                                             |
|                                                                             |
|o5 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i6 : assert isWellDefined h                                                  |
+-----------------------------------------------------------------------------+
|i7 : assert(target h == Ext^2(S^1/I, S^1/I))                                 |
+-----------------------------------------------------------------------------+
|i8 : C = yonedaExtension h                                                   |
|                                                                             |
|                                                        1                    |
|o8 = cokernel | x_0^2 x_0x_1 x_1^2 x_0x_2 x_1x_2 | <-- S  <-- cokernel {2} | |
|                                                                       {2} | |
|     0                                                 1               {2} | |
|                                                                       {2} | |
|                                                                       {2} | |
|                                                                       {2} | |
|                                                                             |
|                                                              2              |
|                                                                             |
|o8 : Complex                                                                 |
|-----------------------------------------------------------------------------|
|-x_1 0    -x_2 0    0    0    0     0      0     0      0      | <-- cokernel|
|x_0  -x_1 0    -x_2 0    0    0     0      0     0      0      |             |
|0    x_0  0    0    0    -x_2 0     0      0     0      0      |     3       |
|0    0    x_0  x_1  -x_1 0    0     0      0     0      0      |             |
|0    0    0    0    x_0  x_1  0     0      0     0      0      |             |
|-x_0 x_1  0    0    x_2  0    x_0^2 x_0x_1 x_1^2 x_0x_2 x_1x_2 |             |
|-----------------------------------------------------------------------------|
|| x_0^2 x_0x_1 x_1^2 x_0x_2 x_1x_2 |                                         |
+-----------------------------------------------------------------------------+
|i9 : assert isWellDefined C                                                  |
+-----------------------------------------------------------------------------+
|i10 : assert isHomogeneous C                                                 |
+-----------------------------------------------------------------------------+
|i11 : assert(HH C == 0)                                                      |
+-----------------------------------------------------------------------------+
|i12 : assert(coker yonedaProduct(E1,E1) == 0)                                |
+-----------------------------------------------------------------------------+

In our second example, all three modules in the triple are distinct and the
image of the Yoneda product is not surjective.

+-----------------------------------------------------------------------------+
|i13 : R = S/(x_0*x_1, x_2*x_3);                                              |
+-----------------------------------------------------------------------------+
|i14 : E1 = Ext^1(R^1/(x_0, x_2), R^1/(x_0, x_2, x_3))                        |
|                                                                             |
|o14 = subquotient ({-1} | 0 x_3 x_2 x_0 |, {-1} | 0 x_3 x_2 x_0 0   0   0    |
|                   {-1} | 1 0   0   0   |  {-1} | 0 0   0   0   x_3 x_2 x_0  |
|                                                                             |
|                                2                                            |
|o14 : R-module, subquotient of R                                             |
|-----------------------------------------------------------------------------|
||)                                                                           |
||                                                                            |
+-----------------------------------------------------------------------------+
|i15 : E2 = Ext^2(R^1/(x_0, x_2, x_3), R^1/(x_0, x_1, x_2, x_3))              |
|                                                                             |
|o15 = cokernel {-2} | 0 0 0 x_3 x_2 x_1 x_0 0   0   0   0   0   0   0   0    |
|               {-2} | 0 0 0 0   0   0   0   x_3 x_2 x_1 x_0 0   0   0   0    |
|               {-2} | 0 0 0 0   0   0   0   0   0   0   0   x_3 x_2 x_1 x_0  |
|               {-2} | 0 0 0 0   0   0   0   0   0   0   0   0   0   0   0    |
|               {-2} | 0 0 0 0   0   0   0   0   0   0   0   0   0   0   0    |
|                                                                             |
|                             5                                               |
|o15 : R-module, quotient of R                                                |
|-----------------------------------------------------------------------------|
|0   0   0   0   0   0   0   0   |                                            |
|0   0   0   0   0   0   0   0   |                                            |
|0   0   0   0   0   0   0   0   |                                            |
|x_3 x_2 x_1 x_0 0   0   0   0   |                                            |
|0   0   0   0   x_3 x_2 x_1 x_0 |                                            |
+-----------------------------------------------------------------------------+
|i16 : E3 = Ext^3(R^1/(x_0, x_2), R^1/(x_0, x_1, x_2, x_3))                   |
|                                                                             |
|o16 = cokernel {-3} | 0 0 0 x_3 x_2 x_1 x_0 0   0   0   0   0   0   0   0    |
|               {-3} | 0 0 0 0   0   0   0   x_3 x_2 x_1 x_0 0   0   0   0    |
|               {-3} | 0 0 0 0   0   0   0   0   0   0   0   x_3 x_2 x_1 x_0  |
|               {-3} | 0 0 0 0   0   0   0   0   0   0   0   0   0   0   0    |
|                                                                             |
|                             4                                               |
|o16 : R-module, quotient of R                                                |
|-----------------------------------------------------------------------------|
|0   0   0   0   |                                                            |
|0   0   0   0   |                                                            |
|0   0   0   0   |                                                            |
|x_3 x_2 x_1 x_0 |                                                            |
+-----------------------------------------------------------------------------+
|i17 : h = yonedaProduct(E1_{0}, E2_{1})                                      |
|                                                                             |
|o17 = {-3} | 1 |                                                             |
|      {-3} | 0 |                                                             |
|      {-3} | 0 |                                                             |
|      {-3} | 0 |                                                             |
|                                                                             |
|o17 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i18 : assert isWellDefined h                                                 |
+-----------------------------------------------------------------------------+
|i19 : assert(target h == E3)                                                 |
+-----------------------------------------------------------------------------+
|i20 : C = yonedaExtension h                                                  |
|                                                                             |
|                                1      2                                     |
|o20 = cokernel | x_0 x_2 | <-- R  <-- R  <-- cokernel {2} | x_2 -x_0 0   0   |
|                                                      {2} | 0   x_3  x_1 0   |
|      0                        1      2               {2} | 0   0    x_2 x_0 |
|                                                      {3} | 1   0    0   0   |
|                                                                             |
|                                             3                               |
|                                                                             |
|o20 : Complex                                                                |
|-----------------------------------------------------------------------------|
|0   0   0   0   | <-- cokernel | x_0 x_1 x_2 x_3 |                           |
|0   0   0   0   |                                                            |
|0   0   0   0   |     4                                                      |
|x_0 x_1 x_2 x_3 |                                                            |
+-----------------------------------------------------------------------------+
|i21 : assert isWellDefined C                                                 |
+-----------------------------------------------------------------------------+
|i22 : assert isHomogeneous C                                                 |
+-----------------------------------------------------------------------------+
|i23 : assert(HH C == 0)                                                      |
+-----------------------------------------------------------------------------+
|i24 : assert(coker yonedaProduct(E1, E2) != 0)                               |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Ext -- information about functorial
    properties
  * yonedaProduct(Module,Module), --
    make the product map between Ext modules

Ways to use this method:
========================

  * yonedaProduct(Matrix,Matrix), --
    make the product of two elements in Ext modules

yonedaProduct(Module,Module) -- make the product map between Ext modules
************************************************************************

Synopsis
========

  * Function: yonedaProduct,
  * Usage:
        yonedaProduct(D,E)
  * Inputs:
      * D, a module (Macaulay2Doc), having the form
        $\operatorname{Ext}_R^d(L,M)$
      * E, a module (Macaulay2Doc), having the form
        $\operatorname{Ext}_R^e(M,N)$
  * Outputs:
      * a matrix (Macaulay2Doc), defining a map from
        $\operatorname{Ext}_R^d(L,M) \otimes_R \operatorname{Ext}_R^e(M,N)$ to
        $\operatorname{Ext}_R^{d+e}(L,N)$

Description
===========

For any triple $(L, M, N)$ of $R$-modules, the Yoneda product is a pairing
between $\operatorname{Ext}$-modules

$\phantom{WWWW} \operatorname{Ext}_R^d(L,M) \otimes \operatorname{Ext}_R^e(M,N)
\to \operatorname{Ext}_R^{d+e}(L,N). $

Given $D = \operatorname{Ext}_R^d(L,M)$ and  $E = \operatorname{Ext}_R^e(M,N)$,
this method returns this pairing. To compute the product of a pair of elements,
see yonedaProduct(Matrix,Matrix).

Specifically, for an element of $\operatorname{Ext}_R^{e}(M,N)$, thought of as
an extension

$\phantom{WWWW} 0 \leftarrow M \leftarrow F_{0} \leftarrow F_{1} \leftarrow
\dotsb \leftarrow F_{e-2} \leftarrow P \leftarrow N \leftarrow 0, $

and for an element of $\operatorname{Ext}_R^{d}(L,M)$, thought of as an
extension

$\phantom{WWWW} 0 \leftarrow L \leftarrow G_{0} \leftarrow G_1 \leftarrow
\dotsb \leftarrow G_{d-2} \leftarrow Q \leftarrow M \leftarrow 0, $

the Yoneda product corresponds to

$\phantom{WWWW} 0 \leftarrow L \leftarrow G_{0} \leftarrow G_{1} \leftarrow
\dotsb \leftarrow Q \leftarrow F_{0} \leftarrow F_{1} \leftarrow \dotsb
\leftarrow P \leftarrow N \leftarrow 0, $

where the map from $F_0$ to $Q$ factors through $M$.  For more information
about extensions, see yonedaExtension.

Alternatively, the module $\operatorname{Ext}^d_R(L,M)$ is constructed from a
free resolution $G$ of $L$,

$\phantom{WWWW} 0 \leftarrow L \leftarrow G_0 \leftarrow G_1 \leftarrow \dotsb
\leftarrow G_d \leftarrow \dotsb, $

by taking the homology of the complex $\operatorname{Hom}_R(G, M)$. An element
of $\operatorname{Ext}^d_R(L,M)$ is represented by an element of
$\operatorname{Hom}_R(G_d, M)$.  This map extends to a complex map having
degree $-d$ from $G$ to the free resolution $F$ of $M$. The Yoneda product is
the composition of the map of chain complexes from $G$ to $F$ with the map of
chain complexes having degree $-e$ from $F$ to a free resolution of $N$. For
more information about these maps, see yonedaMap.

In our first example, the image of the tensor product of two
$\operatorname{Ext}^1$-modules happens to generate the the
$\operatorname{Ext}^2$-module.

+-----------------------------------------------------------------------------+
|i1 : S = ZZ/101[x_0..x_3];                                                   |
+-----------------------------------------------------------------------------+
|i2 : I = borel monomialIdeal(x_1*x_2)                                        |
|                                                                             |
|                     2         2                                             |
|o2 = monomialIdeal (x , x x , x , x x , x x )                                |
|                     0   0 1   1   0 2   1 2                                 |
|                                                                             |
|o2 : MonomialIdeal of S                                                      |
+-----------------------------------------------------------------------------+
|i3 : E1 = Ext^1(S^1/I, S^1/I)                                                |
|                                                                             |
|o3 = subquotient ({-2} | x_1 x_0 0   0   0   0   0   0   0   0   0   0   |,  |
|                  {-2} | 0   0   x_1 x_0 0   0   0   0   0   0   0   0   |   |
|                  {-2} | 0   0   0   0   x_1 x_0 0   0   0   0   0   0   |   |
|                  {-2} | 0   0   0   0   0   0   x_2 x_1 x_0 0   0   0   |   |
|                  {-2} | 0   0   0   0   0   0   0   0   0   x_2 x_1 x_0 |   |
|                                                                             |
|                               5                                             |
|o3 : S-module, subquotient of S                                              |
|-----------------------------------------------------------------------------|
|{-2} | 0 x_1x_2 x_0x_2 x_1^2 x_0x_1 x_0^2 0      0      0     0      0       |
|{-2} | 0 0      0      0     0      0     x_1x_2 x_0x_2 x_1^2 x_0x_1 x_0^2   |
|{-2} | 0 0      0      0     0      0     0      0      0     0      0       |
|{-2} | 0 0      0      0     0      0     0      0      0     0      0       |
|{-2} | 0 0      0      0     0      0     0      0      0     0      0       |
|-----------------------------------------------------------------------------|
|0      0      0     0      0     0      0      0     0      0     0          |
|0      0      0     0      0     0      0      0     0      0     0          |
|x_1x_2 x_0x_2 x_1^2 x_0x_1 x_0^2 0      0      0     0      0     0          |
|0      0      0     0      0     x_1x_2 x_0x_2 x_1^2 x_0x_1 x_0^2 0          |
|0      0      0     0      0     0      0      0     0      0     x_1x_2     |
|-----------------------------------------------------------------------------|
|0      0     0      0     |)                                                 |
|0      0     0      0     |                                                  |
|0      0     0      0     |                                                  |
|0      0     0      0     |                                                  |
|x_0x_2 x_1^2 x_0x_1 x_0^2 |                                                  |
+-----------------------------------------------------------------------------+
|i4 : h = yonedaProduct(E1, E1)                                               |
|                                                                             |
|o4 = {-2} | 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 1 0 0 0 -1 0 0 0 0 0 0 0 -1 0  0 0 0|
|     {-2} | 0 0 0 0 0 1 0 0 0 0  0 0 0 0 0 1 0 0 0  0 0 0 0 0 0 0 0  -1 0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  1 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 1 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  1 0 0 0 0 0 0 0 0  1 0 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 1 0 0 0 0 0 0 0  0 1 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0|
|     {-2} | 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0|
|     ------------------------------------------------------------------------|
|     0 0 0  0 0 -1 0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 1  0 0 0  -1 0 0 0 0 1  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 -1 0 0 0  0  1 0 0 0 -1 0 0 0 0 0 0 0 -1 0  0 0 0 0 0 0 0  0 -1 0  0|
|     0 0 0  0 0 0  0  0 1 0 0 0  0 0 0 0 0 0 0 0  -1 0 0 0 0 0 1 0  0 0  -1 0|
|     0 0 0  0 0 0  0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 0  0 0 0  0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 0  0 0 0  0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 0  0 0 0  0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 0  1 0 0  0  0 0 0 0 0  1 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 0  0 1 0  0  0 0 0 0 0  0 1 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 0  0 0 0  0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 0  0 0 0  0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 0  0 0 0  0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 -1 0 0  0  0|
|     0 0 0  0 0 0  0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 0  0 0 0  0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  0 0  0  0|
|     0 0 0  0 0 0  0  0 0 0 0 0  0 0 0 0 0 0 0 0  0  0 0 0 0 0 0 0  1 0  0  0|
|     ------------------------------------------------------------------------|
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 1 0  0  0  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  0  -1 0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  0  1  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 1 0  0 0 0 0 0 0 0 0 0 0 0 0  0  0  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  0  0  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 -1 0  0  0 0  0 0 -1 0  0 0  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  -1 0  1 0  0 0 0  -1 1 0  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  0  0  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  0  0  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  0  0  0 -1 0 0 0  0  0 -1 0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  0  1  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  0  0  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0 1  0 0 0  0  0 1  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  0  0  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0  0  0  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     0 0 0 0 0  1 0 0 0 0 0 0 0 0 0 0 0  0  0  0 0  0 0 0  0  0 0  0 0 0 0 0 |
|     ------------------------------------------------------------------------|
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 0  0 0 0  0  0 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 0  0 0 0  0  0 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 0  0 0 0  0  0 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  -1 0 0  0 0 0  0  0 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 0  0 0 0  0  0 0 |
|     0 -1 0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 0  0 0 0  0  0 0 |
|     0 0  -1 1 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  -1 0  0  0 0  0 0 -1 0  0 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 0  0 0 0  0  0 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  -1 0  0  0 0  0 0 -1 0  0 0 |
|     0 0  0  0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 0  0 0 0  0  0 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0  0  0  0 0  0 0 0  0  0 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 0  0 0 0  0  0 0 |
|     0 0  0  0 1  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  -1 0  1 0  0 0 0  -1 1 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 0  0 0 0  0  0 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 0  0 0 0  0  0 0 |
|     0 0  0  0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0 -1 0 0 0  0  0 -1|
|     ------------------------------------------------------------------------|
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 -1 0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 -1 0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  -1 1 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 0  0 0 0 0 0 0 0 0 |                                |
|     0 0 0 0 0 0 0  0  0 -1 0 0 0 0 0 0 0 0 |                                |
|                                                                             |
|o4 : Matrix                                                                  |
+-----------------------------------------------------------------------------+
|i5 : assert isWellDefined h                                                  |
+-----------------------------------------------------------------------------+
|i6 : assert(target h == Ext^2(S^1/I, S^1/I))                                 |
+-----------------------------------------------------------------------------+
|i7 : coker h == 0                                                            |
|                                                                             |
|o7 = true                                                                    |
+-----------------------------------------------------------------------------+

In our second example, all three modules in the triple are distinct and the
image of the Yoneda product is not surjective.

+-----------------------------------------------------------------------------+
|i8 : R = S/(x_0*x_1, x_2*x_3);                                               |
+-----------------------------------------------------------------------------+
|i9 : E1 = Ext^1(R^1/(x_0, x_2), R^1/(x_0, x_2, x_3))                         |
|                                                                             |
|o9 = subquotient ({-1} | 0 x_3 x_2 x_0 |, {-1} | 0 x_3 x_2 x_0 0   0   0   |)|
|                  {-1} | 1 0   0   0   |  {-1} | 0 0   0   0   x_3 x_2 x_0 | |
|                                                                             |
|                               2                                             |
|o9 : R-module, subquotient of R                                              |
+-----------------------------------------------------------------------------+
|i10 : E2 = Ext^2(R^1/(x_0, x_2, x_3), R^1/(x_0, x_1, x_2, x_3))              |
|                                                                             |
|o10 = cokernel {-2} | 0 0 0 x_3 x_2 x_1 x_0 0   0   0   0   0   0   0   0    |
|               {-2} | 0 0 0 0   0   0   0   x_3 x_2 x_1 x_0 0   0   0   0    |
|               {-2} | 0 0 0 0   0   0   0   0   0   0   0   x_3 x_2 x_1 x_0  |
|               {-2} | 0 0 0 0   0   0   0   0   0   0   0   0   0   0   0    |
|               {-2} | 0 0 0 0   0   0   0   0   0   0   0   0   0   0   0    |
|                                                                             |
|                             5                                               |
|o10 : R-module, quotient of R                                                |
|-----------------------------------------------------------------------------|
|0   0   0   0   0   0   0   0   |                                            |
|0   0   0   0   0   0   0   0   |                                            |
|0   0   0   0   0   0   0   0   |                                            |
|x_3 x_2 x_1 x_0 0   0   0   0   |                                            |
|0   0   0   0   x_3 x_2 x_1 x_0 |                                            |
+-----------------------------------------------------------------------------+
|i11 : E3 = Ext^3(R^1/(x_0, x_2), R^1/(x_0, x_1, x_2, x_3))                   |
|                                                                             |
|o11 = cokernel {-3} | 0 0 0 x_3 x_2 x_1 x_0 0   0   0   0   0   0   0   0    |
|               {-3} | 0 0 0 0   0   0   0   x_3 x_2 x_1 x_0 0   0   0   0    |
|               {-3} | 0 0 0 0   0   0   0   0   0   0   0   x_3 x_2 x_1 x_0  |
|               {-3} | 0 0 0 0   0   0   0   0   0   0   0   0   0   0   0    |
|                                                                             |
|                             4                                               |
|o11 : R-module, quotient of R                                                |
|-----------------------------------------------------------------------------|
|0   0   0   0   |                                                            |
|0   0   0   0   |                                                            |
|0   0   0   0   |                                                            |
|x_3 x_2 x_1 x_0 |                                                            |
+-----------------------------------------------------------------------------+
|i12 : h = yonedaProduct(E1, E2)                                              |
|                                                                             |
|o12 = {-3} | 0 1 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                      |
|      {-3} | 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                      |
|      {-3} | 0 0 0  0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                      |
|      {-3} | 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |                      |
|                                                                             |
|o12 : Matrix                                                                 |
+-----------------------------------------------------------------------------+
|i13 : assert isWellDefined h                                                 |
+-----------------------------------------------------------------------------+
|i14 : assert(target h == E3)                                                 |
+-----------------------------------------------------------------------------+
|i15 : prune coker h                                                          |
|                                                                             |
|o15 = cokernel {-3} | x_3 x_2 x_1 x_0 |                                      |
|                                                                             |
|                             1                                               |
|o15 : R-module, quotient of R                                                |
+-----------------------------------------------------------------------------+

See also
========

  * Working with Ext -- information about functorial
    properties
  * yonedaProduct(Matrix,Matrix), --
    make the product of two elements in Ext modules

Ways to use this method:
========================

  * yonedaProduct(Module,Module), --
    make the product map between Ext modules