An algebra is said to be graded commutative if it is endowed with a grading and its multiplication satisfies the Koszul sign convention: $$yx = (-1)^{ij} xy$$ if $$x$$ and $$y$$ are homogeneous of degrees $$i$$ and $$j$$, respectively. Thus the multiplication is anticommutative for odd degree elements, commutative otherwise. Commutative differential graded algebras are graded commutative algebras endowed with a graded differential of degree 1. These algebras can be graded over the integers or they can be multi-graded (i.e., graded over a finite rank free abelian group $$\ZZ^n$$); if multi-graded, the total degree is used in the Koszul sign convention, and the differential must have total degree 1.

EXAMPLES:

All of these algebras may be constructed with the function GradedCommutativeAlgebra(). For most users, that will be the main function of interest. See its documentation for many more examples.

We start by constructing some graded commutative algebras. Generators have degree 1 by default:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ)
sage: x.degree()
1
sage: x^2
0
sage: y*x
-x*y
sage: B.<a,b> = GradedCommutativeAlgebra(QQ, degrees = (2,3))
sage: a.degree()
2
sage: b.degree()
3

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> x.degree()
1
>>> x**Integer(2)
0
>>> y*x
-x*y
>>> B = GradedCommutativeAlgebra(QQ, degrees = (Integer(2),Integer(3)), names=('a', 'b',)); (a, b,) = B._first_ngens(2)
>>> a.degree()
2
>>> b.degree()
3


Once we have defined a graded commutative algebra, it is easy to define a differential on it using the GCAlgebra.cdg_algebra() method:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1,1,2))
sage: B = A.cdg_algebra({x: x*y, y: -x*y})
sage: B
Commutative Differential Graded Algebra with generators ('x', 'y', 'z')
in degrees (1, 1, 2) over Rational Field with differential:
x --> x*y
y --> -x*y
z --> 0
sage: B.cohomology(3)
Free module generated by {[x*z + y*z]} over Rational Field
sage: B.cohomology(4)
Free module generated by {[z^2]} over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1),Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> B = A.cdg_algebra({x: x*y, y: -x*y})
>>> B
Commutative Differential Graded Algebra with generators ('x', 'y', 'z')
in degrees (1, 1, 2) over Rational Field with differential:
x --> x*y
y --> -x*y
z --> 0
>>> B.cohomology(Integer(3))
Free module generated by {[x*z + y*z]} over Rational Field
>>> B.cohomology(Integer(4))
Free module generated by {[z^2]} over Rational Field


We can also compute algebra generators for the cohomology in a range of degrees, and in this case we compute up to degree 10:

sage: B.cohomology_generators(10)
{1: [x + y], 2: [z]}

>>> from sage.all import *
>>> B.cohomology_generators(Integer(10))
{1: [x + y], 2: [z]}


AUTHORS:

• Miguel Marco, John Palmieri (2014-07): initial version

class sage.algebras.commutative_dga.CohomologyClass(x, cdga=None)[source]#

A class for representing cohomology classes.

This just has _repr_ and _latex_ methods which put brackets around the object’s name.

EXAMPLES:

sage: from sage.algebras.commutative_dga import CohomologyClass
sage: CohomologyClass(3)
[3]
sage: CohomologyClass(x^2 + 2*y*z, A)
[2*y*z + x^2]

>>> from sage.all import *
>>> from sage.algebras.commutative_dga import CohomologyClass
>>> CohomologyClass(Integer(3))
[3]
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(2),Integer(2),Integer(3),Integer(3)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> CohomologyClass(x**Integer(2) + Integer(2)*y*z, A)
[2*y*z + x^2]

representative()[source]#

Return the representative of self.

EXAMPLES:

sage: from sage.algebras.commutative_dga import CohomologyClass
sage: x = CohomologyClass(sin)                                              # needs sage.symbolic
sage: x.representative() == sin                                             # needs sage.symbolic
True

>>> from sage.all import *
>>> from sage.algebras.commutative_dga import CohomologyClass
>>> x = CohomologyClass(sin)                                              # needs sage.symbolic
>>> x.representative() == sin                                             # needs sage.symbolic
True

class sage.algebras.commutative_dga.Differential(A, im_gens)[source]#

Differential of a commutative graded algebra.

INPUT:

• A – algebra where the differential is defined

• im_gens – tuple containing the image of each generator

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 2, 3))
sage: B = A.cdg_algebra({x: x*y, y: -x*y , z: t})
sage: B
Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't')
in degrees (1, 1, 2, 3) over Rational Field with differential:
x --> x*y
y --> -x*y
z --> t
t --> 0
sage: B.differential()(x)
x*y

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(1), Integer(2), Integer(3)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> B = A.cdg_algebra({x: x*y, y: -x*y , z: t})
>>> B
Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't')
in degrees (1, 1, 2, 3) over Rational Field with differential:
x --> x*y
y --> -x*y
z --> t
t --> 0
>>> B.differential()(x)
x*y

coboundaries(n)[source]#

The n-th coboundary group of the algebra.

This is a vector space over the base field $$F$$, and it is returned as a subspace of the vector space $$F^d$$, where the n-th homogeneous component has dimension $$d$$.

INPUT:

• n – degree

EXAMPLES:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 2))
sage: d = A.differential({z: x*z})
sage: d.coboundaries(2)
Vector space of degree 2 and dimension 0 over Rational Field
Basis matrix:
[]
sage: d.coboundaries(3)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]
sage: d.coboundaries(1)
Vector space of degree 2 and dimension 0 over Rational Field
Basis matrix:
[]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(1), Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> d = A.differential({z: x*z})
>>> d.coboundaries(Integer(2))
Vector space of degree 2 and dimension 0 over Rational Field
Basis matrix:
[]
>>> d.coboundaries(Integer(3))
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]
>>> d.coboundaries(Integer(1))
Vector space of degree 2 and dimension 0 over Rational Field
Basis matrix:
[]

cocycles(n)[source]#

The n-th cocycle group of the algebra.

This is a vector space over the base field $$F$$, and it is returned as a subspace of the vector space $$F^d$$, where the n-th homogeneous component has dimension $$d$$.

INPUT:

• n – degree

EXAMPLES:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 2))
sage: d = A.differential({z: x*z})
sage: d.cocycles(2)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(1), Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> d = A.differential({z: x*z})
>>> d.cocycles(Integer(2))
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]

cohomology(n)[source]#

The n-th cohomology group of self.

This is a vector space over the base ring, defined as the quotient cocycles/coboundaries. The elements of the quotient are lifted to the vector space of cocycles, and this is described in terms of those lifts.

INPUT:

• n – degree

EXAMPLES:

sage: A.<a,b,c,d,e> = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 1, 1, 1))
sage: d = A.differential({d: a*b, e: b*c})
sage: d.cohomology(2)
Free module generated by {[a*c], [a*d], [b*d], [c*d - a*e], [b*e], [c*e]} over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(1), Integer(1), Integer(1), Integer(1)), names=('a', 'b', 'c', 'd', 'e',)); (a, b, c, d, e,) = A._first_ngens(5)
>>> d = A.differential({d: a*b, e: b*c})
>>> d.cohomology(Integer(2))
Free module generated by {[a*c], [a*d], [b*d], [c*d - a*e], [b*e], [c*e]} over Rational Field


Compare to cohomology_raw():

sage: d.cohomology_raw(2)
Vector space quotient V/W of dimension 6 over Rational Field where
V: Vector space of degree 10 and dimension 8 over Rational Field
Basis matrix:
[ 1  0  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  1  0  0  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  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  1  0]
W: Vector space of degree 10 and dimension 2 over Rational Field
Basis matrix:
[1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0]

>>> from sage.all import *
>>> d.cohomology_raw(Integer(2))
Vector space quotient V/W of dimension 6 over Rational Field where
V: Vector space of degree 10 and dimension 8 over Rational Field
Basis matrix:
[ 1  0  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  1  0  0  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  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  1  0]
W: Vector space of degree 10 and dimension 2 over Rational Field
Basis matrix:
[1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0]

cohomology_raw(n)[source]#

The n-th cohomology group of self.

This is a vector space over the base ring, and it is returned as the quotient cocycles/coboundaries.

INPUT:

• n – degree

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3, 4))
sage: d = A.differential({t: x*z, x: z, y: z})
sage: d.cohomology_raw(4)
Vector space quotient V/W of dimension 2 over Rational Field where
V: Vector space of degree 4 and dimension 2 over Rational Field
Basis matrix:
[   1    0    0   -2]
[   0    1 -1/2   -1]
W: Vector space of degree 4 and dimension 0 over Rational Field
Basis matrix:
[]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(2), Integer(2), Integer(3), Integer(4)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> d = A.differential({t: x*z, x: z, y: z})
>>> d.cohomology_raw(Integer(4))
Vector space quotient V/W of dimension 2 over Rational Field where
V: Vector space of degree 4 and dimension 2 over Rational Field
Basis matrix:
[   1    0    0   -2]
[   0    1 -1/2   -1]
W: Vector space of degree 4 and dimension 0 over Rational Field
Basis matrix:
[]


Compare to cohomology():

sage: d.cohomology(4)
Free module generated by {[x^2 - 2*t], [x*y - 1/2*y^2 - t]} over Rational Field

>>> from sage.all import *
>>> d.cohomology(Integer(4))
Free module generated by {[x^2 - 2*t], [x*y - 1/2*y^2 - t]} over Rational Field

differential_matrix(n)[source]#

The matrix that gives the differential in degree n.

INPUT:

• n – degree

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(GF(5), degrees=(2, 2, 3, 4))
sage: d = A.differential({t: x*z, x: z, y: z})
sage: d.differential_matrix(4)
[2 0]
[1 1]
[0 2]
[1 0]
sage: A.inject_variables()
Defining x, y, z, t
sage: d(t)
x*z
sage: d(y^2)
2*y*z
sage: d(x*y)
x*z + y*z
sage: d(x^2)
2*x*z

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(GF(Integer(5)), degrees=(Integer(2), Integer(2), Integer(3), Integer(4)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> d = A.differential({t: x*z, x: z, y: z})
>>> d.differential_matrix(Integer(4))
[2 0]
[1 1]
[0 2]
[1 0]
>>> A.inject_variables()
Defining x, y, z, t
>>> d(t)
x*z
>>> d(y**Integer(2))
2*y*z
>>> d(x*y)
x*z + y*z
>>> d(x**Integer(2))
2*x*z

homology(n)[source]#

The n-th cohomology group of self.

This is a vector space over the base ring, defined as the quotient cocycles/coboundaries. The elements of the quotient are lifted to the vector space of cocycles, and this is described in terms of those lifts.

INPUT:

• n – degree

EXAMPLES:

sage: A.<a,b,c,d,e> = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 1, 1, 1))
sage: d = A.differential({d: a*b, e: b*c})
sage: d.cohomology(2)
Free module generated by {[a*c], [a*d], [b*d], [c*d - a*e], [b*e], [c*e]} over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(1), Integer(1), Integer(1), Integer(1)), names=('a', 'b', 'c', 'd', 'e',)); (a, b, c, d, e,) = A._first_ngens(5)
>>> d = A.differential({d: a*b, e: b*c})
>>> d.cohomology(Integer(2))
Free module generated by {[a*c], [a*d], [b*d], [c*d - a*e], [b*e], [c*e]} over Rational Field


Compare to cohomology_raw():

sage: d.cohomology_raw(2)
Vector space quotient V/W of dimension 6 over Rational Field where
V: Vector space of degree 10 and dimension 8 over Rational Field
Basis matrix:
[ 1  0  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  1  0  0  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  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  1  0]
W: Vector space of degree 10 and dimension 2 over Rational Field
Basis matrix:
[1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0]

>>> from sage.all import *
>>> d.cohomology_raw(Integer(2))
Vector space quotient V/W of dimension 6 over Rational Field where
V: Vector space of degree 10 and dimension 8 over Rational Field
Basis matrix:
[ 1  0  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  1  0  0  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  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  1  0]
W: Vector space of degree 10 and dimension 2 over Rational Field
Basis matrix:
[1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0]

class sage.algebras.commutative_dga.DifferentialGCAlgebra(A, differential)[source]#

Bases: GCAlgebra

INPUT:

• A – a graded commutative algebra; that is, an instance of GCAlgebra

• differential – a differential

As described in the module-level documentation, these are graded algebras for which oddly graded elements anticommute and evenly graded elements commute, and on which there is a graded differential of degree 1.

These algebras should be graded over the integers; multi-graded algebras should be constructed using DifferentialGCAlgebra_multigraded instead.

Note that a natural way to construct these is to use the GradedCommutativeAlgebra() function and the GCAlgebra.cdg_algebra() method.

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3, 3))
sage: A.cdg_algebra({z: x*y})
Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 2, 3, 3) over Rational Field with differential:
x --> 0
y --> 0
z --> x*y
t --> 0

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(2), Integer(2), Integer(3), Integer(3)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> A.cdg_algebra({z: x*y})
Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 2, 3, 3) over Rational Field with differential:
x --> 0
y --> 0
z --> x*y
t --> 0


Alternatively, starting with GradedCommutativeAlgebra():

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3, 3))
sage: A.cdg_algebra(differential={z: x*y})
Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 2, 3, 3) over Rational Field with differential:
x --> 0
y --> 0
z --> x*y
t --> 0

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(2), Integer(2), Integer(3), Integer(3)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> A.cdg_algebra(differential={z: x*y})
Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 2, 3, 3) over Rational Field with differential:
x --> 0
y --> 0
z --> x*y
t --> 0


See the function GradedCommutativeAlgebra() for more examples.

class Element(A, rep)[source]#

Bases: Element

cohomology_class()[source]#

Return the cohomology class of a homogeneous cycle, as an element of the corresponding cohomology group.

EXAMPLES:

sage: A.<e1,e2,e3,e4,e5> = GradedCommutativeAlgebra(QQ)
sage: B = A.cdg_algebra({e5: e1*e2+e3*e4})
sage: B.inject_variables()
Defining e1, e2, e3, e4, e5
sage: a = e1*e3*e5 - 3*e2*e3*e5
sage: a.cohomology_class()
B[[e1*e3*e5]] - 3*B[[e2*e3*e5]]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, names=('e1', 'e2', 'e3', 'e4', 'e5',)); (e1, e2, e3, e4, e5,) = A._first_ngens(5)
>>> B = A.cdg_algebra({e5: e1*e2+e3*e4})
>>> B.inject_variables()
Defining e1, e2, e3, e4, e5
>>> a = e1*e3*e5 - Integer(3)*e2*e3*e5
>>> a.cohomology_class()
B[[e1*e3*e5]] - 3*B[[e2*e3*e5]]

differential()[source]#

The differential on this element.

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3, 4))
sage: B = A.cdg_algebra({t: x*z, x: z, y: z})
sage: B.inject_variables()
Defining x, y, z, t
sage: x.differential()
z
sage: (-1/2 * x^2 + t).differential()
0

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(2), Integer(2), Integer(3), Integer(4)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> B = A.cdg_algebra({t: x*z, x: z, y: z})
>>> B.inject_variables()
Defining x, y, z, t
>>> x.differential()
z
>>> (-Integer(1)/Integer(2) * x**Integer(2) + t).differential()
0

is_coboundary()[source]#

Return True if self is a coboundary and False otherwise.

This raises an error if the element is not homogeneous.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=(1,2,2))
sage: B = A.cdg_algebra(differential={b: a*c})
sage: x,y,z = B.gens()
sage: x.is_coboundary()
False
sage: (x*z).is_coboundary()
True
sage: (x*z + x*y).is_coboundary()
False
sage: (x*z + y**2).is_coboundary()
Traceback (most recent call last):
...
ValueError: this element is not homogeneous

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(2),Integer(2)), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> B = A.cdg_algebra(differential={b: a*c})
>>> x,y,z = B.gens()
>>> x.is_coboundary()
False
>>> (x*z).is_coboundary()
True
>>> (x*z + x*y).is_coboundary()
False
>>> (x*z + y**Integer(2)).is_coboundary()
Traceback (most recent call last):
...
ValueError: this element is not homogeneous

is_cohomologous_to(other)[source]#

Return True if self is cohomologous to other and False otherwise.

INPUT:

• other – another element of this algebra

EXAMPLES:

sage: A.<a,b,c,d> = GradedCommutativeAlgebra(QQ, degrees=(1,1,1,1))
sage: B = A.cdg_algebra(differential={a: b*c-c*d})
sage: w, x, y, z = B.gens()
sage: (x*y).is_cohomologous_to(y*z)
True
sage: (x*y).is_cohomologous_to(x*z)
False
sage: (x*y).is_cohomologous_to(x*y)
True

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1),Integer(1),Integer(1)), names=('a', 'b', 'c', 'd',)); (a, b, c, d,) = A._first_ngens(4)
>>> B = A.cdg_algebra(differential={a: b*c-c*d})
>>> w, x, y, z = B.gens()
>>> (x*y).is_cohomologous_to(y*z)
True
>>> (x*y).is_cohomologous_to(x*z)
False
>>> (x*y).is_cohomologous_to(x*y)
True


Two elements whose difference is not homogeneous are cohomologous if and only if they are both coboundaries:

sage: w.is_cohomologous_to(y*z)
False
sage: (x*y-y*z).is_cohomologous_to(x*y*z)
True
sage: (x*y*z).is_cohomologous_to(0)  # make sure 0 works
True

>>> from sage.all import *
>>> w.is_cohomologous_to(y*z)
False
>>> (x*y-y*z).is_cohomologous_to(x*y*z)
True
>>> (x*y*z).is_cohomologous_to(Integer(0))  # make sure 0 works
True

cdg_algebra(differential)[source]#

Construct a differential graded commutative algebra from the underlying graded commutative algebra by specifying a differential. This may be used to get a new differential over the same algebra structure.

INPUT:

• differential – a dictionary defining a differential or a map defining a valid differential

The keys of the dictionary are generators of the algebra, and the associated values are their targets under the differential. Any generators which are not specified are assumed to have zero differential. Alternatively, the differential can be defined using the differential() method; see below for an example.

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(GF(5), degrees=(2, 3, 2, 4))
sage: B = A.quotient(A.ideal(x^3-z*t))
sage: C = B.cdg_algebra({y:t})
sage: C
Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 3, 2, 4) with relations [x^3 - z*t]
over Finite Field of size 5 with differential:
x --> 0
y --> t
z --> 0
t --> 0
sage: C.cdg_algebra({})
Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 3, 2, 4) with relations [x^3 - z*t]
over Finite Field of size 5 with differential:
x --> 0
y --> 0
z --> 0
t --> 0

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(GF(Integer(5)), degrees=(Integer(2), Integer(3), Integer(2), Integer(4)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> B = A.quotient(A.ideal(x**Integer(3)-z*t))
>>> C = B.cdg_algebra({y:t})
>>> C
Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 3, 2, 4) with relations [x^3 - z*t]
over Finite Field of size 5 with differential:
x --> 0
y --> t
z --> 0
t --> 0
>>> C.cdg_algebra({})
Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 3, 2, 4) with relations [x^3 - z*t]
over Finite Field of size 5 with differential:
x --> 0
y --> 0
z --> 0
t --> 0

coboundaries(n)[source]#

The n-th coboundary group of the algebra.

This is a vector space over the base field $$F$$, and it is returned as a subspace of the vector space $$F^d$$, where the n-th homogeneous component has dimension $$d$$.

INPUT:

• n – degree

EXAMPLES:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1,1,2))
sage: B = A.cdg_algebra(differential={z: x*z})
sage: B.coboundaries(2)
Vector space of degree 2 and dimension 0 over Rational Field
Basis matrix:
[]
sage: B.coboundaries(3)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]
sage: B.basis(3)
[x*z, y*z]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1),Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> B = A.cdg_algebra(differential={z: x*z})
>>> B.coboundaries(Integer(2))
Vector space of degree 2 and dimension 0 over Rational Field
Basis matrix:
[]
>>> B.coboundaries(Integer(3))
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]
>>> B.basis(Integer(3))
[x*z, y*z]

cocycles(n)[source]#

The n-th cocycle group of the algebra.

This is a vector space over the base field $$F$$, and it is returned as a subspace of the vector space $$F^d$$, where the n-th homogeneous component has dimension $$d$$.

INPUT:

• n – degree

EXAMPLES:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1,1,2))
sage: B = A.cdg_algebra(differential={z: x*z})
sage: B.cocycles(2)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]
sage: B.basis(2)
[x*y, z]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1),Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> B = A.cdg_algebra(differential={z: x*z})
>>> B.cocycles(Integer(2))
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]
>>> B.basis(Integer(2))
[x*y, z]

cohomology(n)[source]#

The n-th cohomology group of self.

This is a vector space over the base ring, defined as the quotient cocycles/coboundaries. The elements of the quotient are lifted to the vector space of cocycles, and this is described in terms of those lifts.

INPUT:

• n – degree

EXAMPLES:

sage: A.<a,b,c,d,e> = GradedCommutativeAlgebra(QQ, degrees=(1,1,1,1,1))
sage: B = A.cdg_algebra({d: a*b, e: b*c})
sage: B.cohomology(2)
Free module generated by {[a*c], [a*d], [b*d], [c*d - a*e], [b*e], [c*e]}
over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1),Integer(1),Integer(1),Integer(1)), names=('a', 'b', 'c', 'd', 'e',)); (a, b, c, d, e,) = A._first_ngens(5)
>>> B = A.cdg_algebra({d: a*b, e: b*c})
>>> B.cohomology(Integer(2))
Free module generated by {[a*c], [a*d], [b*d], [c*d - a*e], [b*e], [c*e]}
over Rational Field


Compare to cohomology_raw():

sage: B.cohomology_raw(2)
Vector space quotient V/W of dimension 6 over Rational Field where
V: Vector space of degree 10 and dimension 8 over Rational Field
Basis matrix:
[ 1  0  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  1  0  0  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  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  1  0]
W: Vector space of degree 10 and dimension 2 over Rational Field
Basis matrix:
[1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0]

>>> from sage.all import *
>>> B.cohomology_raw(Integer(2))
Vector space quotient V/W of dimension 6 over Rational Field where
V: Vector space of degree 10 and dimension 8 over Rational Field
Basis matrix:
[ 1  0  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  1  0  0  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  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  1  0]
W: Vector space of degree 10 and dimension 2 over Rational Field
Basis matrix:
[1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0]

cohomology_algebra(max_degree=3)[source]#

Compute a CDGA with trivial differential, that is isomorphic to the cohomology of self up tomax_degree

INPUT:

• max_degree – integer (default: $$3$$); degree to which the result is required to be isomorphic to self’s cohomology.

EXAMPLES:

sage: A.<e1, e2, e3, e4, e5, e6, e7> = GradedCommutativeAlgebra(QQ)
sage: d = A.differential({e1:-e1*e6, e2:-e2*e6, e3:-e3*e6, e4:-e5*e6, e5:e4*e6})
sage: B = A.cdg_algebra(d)
sage: M = B.cohomology_algebra()
sage: M
Commutative Differential Graded Algebra with generators ('x0', 'x1', 'x2')
in degrees (1, 1, 2) over Rational Field with differential:
x0 --> 0
x1 --> 0
x2 --> 0
sage: M.cohomology(1)
Free module generated by {[x0], [x1]} over Rational Field
sage: B.cohomology(1)
Free module generated by {[e6], [e7]} over Rational Field
sage: M.cohomology(2)
Free module generated by {[x0*x1], [x2]} over Rational Field
sage: B.cohomology(2)
Free module generated by {[e4*e5], [e6*e7]} over Rational Field
sage: M.cohomology(3)
Free module generated by {[x0*x2], [x1*x2]} over Rational Field
sage: B.cohomology(3)
Free module generated by {[e4*e5*e6], [e4*e5*e7]} over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, names=('e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7',)); (e1, e2, e3, e4, e5, e6, e7,) = A._first_ngens(7)
>>> d = A.differential({e1:-e1*e6, e2:-e2*e6, e3:-e3*e6, e4:-e5*e6, e5:e4*e6})
>>> B = A.cdg_algebra(d)
>>> M = B.cohomology_algebra()
>>> M
Commutative Differential Graded Algebra with generators ('x0', 'x1', 'x2')
in degrees (1, 1, 2) over Rational Field with differential:
x0 --> 0
x1 --> 0
x2 --> 0
>>> M.cohomology(Integer(1))
Free module generated by {[x0], [x1]} over Rational Field
>>> B.cohomology(Integer(1))
Free module generated by {[e6], [e7]} over Rational Field
>>> M.cohomology(Integer(2))
Free module generated by {[x0*x1], [x2]} over Rational Field
>>> B.cohomology(Integer(2))
Free module generated by {[e4*e5], [e6*e7]} over Rational Field
>>> M.cohomology(Integer(3))
Free module generated by {[x0*x2], [x1*x2]} over Rational Field
>>> B.cohomology(Integer(3))
Free module generated by {[e4*e5*e6], [e4*e5*e7]} over Rational Field

cohomology_generators(max_degree)[source]#

Return lifts of algebra generators for cohomology in degrees at most max_degree.

INPUT:

• max_degree – integer

OUTPUT:

A dictionary keyed by degree, where the corresponding value is a list of cohomology generators in that degree. Actually, the elements are lifts of cohomology generators, which means that they lie in this differential graded algebra. It also means that they are only well-defined up to cohomology, not on the nose.

ALGORITHM:

Reduce a basis of the $$n$$’th cohomology modulo all the degree $$n$$ products of the lower degree cohomologies.

EXAMPLES:

sage: A.<a,x,y> = GradedCommutativeAlgebra(QQ, degrees=(1,2,2))
sage: B = A.cdg_algebra(differential={y: a*x})
sage: B.cohomology_generators(3)
{1: [a], 2: [x], 3: [a*y]}

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(2),Integer(2)), names=('a', 'x', 'y',)); (a, x, y,) = A._first_ngens(3)
>>> B = A.cdg_algebra(differential={y: a*x})
>>> B.cohomology_generators(Integer(3))
{1: [a], 2: [x], 3: [a*y]}


The previous example has infinitely generated cohomology: $$a y^n$$ is a cohomology generator for each $$n$$:

sage: B.cohomology_generators(10)
{1: [a], 2: [x], 3: [a*y], 5: [a*y^2], 7: [a*y^3], 9: [a*y^4]}

>>> from sage.all import *
>>> B.cohomology_generators(Integer(10))
{1: [a], 2: [x], 3: [a*y], 5: [a*y^2], 7: [a*y^3], 9: [a*y^4]}


In contrast, the corresponding algebra in characteristic $$p$$ has finitely generated cohomology:

sage: A3.<a,x,y> = GradedCommutativeAlgebra(GF(3), degrees=(1,2,2))
sage: B3 = A3.cdg_algebra(differential={y: a*x})
sage: B3.cohomology_generators(16)
{1: [a], 2: [x], 3: [a*y], 5: [a*y^2], 6: [y^3]}

>>> from sage.all import *
>>> A3 = GradedCommutativeAlgebra(GF(Integer(3)), degrees=(Integer(1),Integer(2),Integer(2)), names=('a', 'x', 'y',)); (a, x, y,) = A3._first_ngens(3)
>>> B3 = A3.cdg_algebra(differential={y: a*x})
>>> B3.cohomology_generators(Integer(16))
{1: [a], 2: [x], 3: [a*y], 5: [a*y^2], 6: [y^3]}


sage: Cs.<a,b,c,d> = GradedCommutativeAlgebra(GF(2), degrees=(1,2,2,3))
sage: Ds = Cs.cdg_algebra({a:c, b:d})
sage: Ds.cohomology_generators(10)
{2: [a^2], 4: [b^2]}

....:                                         degrees=((1,0), (1,1),
....:                                                  (0,2), (0,3)))
sage: Dm = Cm.cdg_algebra({a:c, b:d})
sage: Dm.cohomology_generators(10)
{2: [a^2], 4: [b^2]}

>>> from sage.all import *
>>> Cs = GradedCommutativeAlgebra(GF(Integer(2)), degrees=(Integer(1),Integer(2),Integer(2),Integer(3)), names=('a', 'b', 'c', 'd',)); (a, b, c, d,) = Cs._first_ngens(4)
>>> Ds = Cs.cdg_algebra({a:c, b:d})
>>> Ds.cohomology_generators(Integer(10))
{2: [a^2], 4: [b^2]}

...                                         degrees=((Integer(1),Integer(0)), (Integer(1),Integer(1)),
...                                                  (Integer(0),Integer(2)), (Integer(0),Integer(3))), names=('a', 'b', 'c', 'd',)); (a, b, c, d,) = Cm._first_ngens(4)
>>> Dm = Cm.cdg_algebra({a:c, b:d})
>>> Dm.cohomology_generators(Integer(10))
{2: [a^2], 4: [b^2]}

cohomology_raw(n)[source]#

The n-th cohomology group of self.

This is a vector space over the base ring, and it is returned as the quotient cocycles/coboundaries.

INPUT:

• n – degree

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees = (2,2,3,4))
sage: B = A.cdg_algebra({t: x*z, x: z, y: z})
sage: B.cohomology_raw(4)
Vector space quotient V/W of dimension 2 over Rational Field where
V: Vector space of degree 4 and dimension 2 over Rational Field
Basis matrix:
[   1    0    0   -2]
[   0    1 -1/2   -1]
W: Vector space of degree 4 and dimension 0 over Rational Field
Basis matrix:
[]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees = (Integer(2),Integer(2),Integer(3),Integer(4)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> B = A.cdg_algebra({t: x*z, x: z, y: z})
>>> B.cohomology_raw(Integer(4))
Vector space quotient V/W of dimension 2 over Rational Field where
V: Vector space of degree 4 and dimension 2 over Rational Field
Basis matrix:
[   1    0    0   -2]
[   0    1 -1/2   -1]
W: Vector space of degree 4 and dimension 0 over Rational Field
Basis matrix:
[]


Compare to cohomology():

sage: B.cohomology(4)
Free module generated by {[x^2 - 2*t], [x*y - 1/2*y^2 - t]} over Rational Field

>>> from sage.all import *
>>> B.cohomology(Integer(4))
Free module generated by {[x^2 - 2*t], [x*y - 1/2*y^2 - t]} over Rational Field

differential(x=None)[source]#

The differential of self.

This returns a map, and so it may be evaluated on elements of this algebra.

EXAMPLES:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1,1,2))
sage: B = A.cdg_algebra({y:x*y, x: y*x})
sage: d = B.differential(); d
Differential of Commutative Differential Graded Algebra
with generators ('x', 'y', 'z') in degrees (1, 1, 2) over Rational Field
Defn: x --> -x*y
y --> x*y
z --> 0
sage: d(y)
x*y

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1),Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> B = A.cdg_algebra({y:x*y, x: y*x})
>>> d = B.differential(); d
Differential of Commutative Differential Graded Algebra
with generators ('x', 'y', 'z') in degrees (1, 1, 2) over Rational Field
Defn: x --> -x*y
y --> x*y
z --> 0
>>> d(y)
x*y


Return the base graded commutative algebra of self.

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3, 3))
sage: D = A.cdg_algebra({z: x*y})
True

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(2), Integer(2), Integer(3), Integer(3)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> D = A.cdg_algebra({z: x*y})
True

homology(n)[source]#

The n-th cohomology group of self.

This is a vector space over the base ring, defined as the quotient cocycles/coboundaries. The elements of the quotient are lifted to the vector space of cocycles, and this is described in terms of those lifts.

INPUT:

• n – degree

EXAMPLES:

sage: A.<a,b,c,d,e> = GradedCommutativeAlgebra(QQ, degrees=(1,1,1,1,1))
sage: B = A.cdg_algebra({d: a*b, e: b*c})
sage: B.cohomology(2)
Free module generated by {[a*c], [a*d], [b*d], [c*d - a*e], [b*e], [c*e]}
over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1),Integer(1),Integer(1),Integer(1)), names=('a', 'b', 'c', 'd', 'e',)); (a, b, c, d, e,) = A._first_ngens(5)
>>> B = A.cdg_algebra({d: a*b, e: b*c})
>>> B.cohomology(Integer(2))
Free module generated by {[a*c], [a*d], [b*d], [c*d - a*e], [b*e], [c*e]}
over Rational Field


Compare to cohomology_raw():

sage: B.cohomology_raw(2)
Vector space quotient V/W of dimension 6 over Rational Field where
V: Vector space of degree 10 and dimension 8 over Rational Field
Basis matrix:
[ 1  0  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  1  0  0  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  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  1  0]
W: Vector space of degree 10 and dimension 2 over Rational Field
Basis matrix:
[1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0]

>>> from sage.all import *
>>> B.cohomology_raw(Integer(2))
Vector space quotient V/W of dimension 6 over Rational Field where
V: Vector space of degree 10 and dimension 8 over Rational Field
Basis matrix:
[ 1  0  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  1  0  0  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  0  0  0  0  0  1  0  0]
[ 0  0  0  0  0  0  0  0  1  0]
W: Vector space of degree 10 and dimension 2 over Rational Field
Basis matrix:
[1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0]

is_formal(i, max_iterations=3)[source]#

Check if the algebra is i-formal. That is, if it is i-quasi-isomorphic to its cohomology algebra.

INPUT:

• i – integer; the degree up to which the formality is checked

• max_iterations – integer (default: $$3$$); the maximum number of iterations used in the computation of the minimal model

Warning

The method is not granted to finish (it can’t, since the minimal model could be infinitely generated in some degrees). The parameter max_iterations controls how many iterations of the method are attempted at each degree. In case they are not enough, an exception is raised. If you think that the result will be finitely generated, you can try to run it again with a higher value for max_iterations.

Moreover, the method uses criteria that are often enough to conclude that the algebra is either formal or non-formal. However, it could happen that the used criteria can not determine the formality. In that case, an error is raised.

EXAMPLES:

sage: A.<e1, e2, e3, e4, e5> = GradedCommutativeAlgebra(QQ)
sage: B = A.cdg_algebra({e5: e1*e2 + e3*e4})
sage: B.is_formal(1)
True
sage: B.is_formal(2)
False

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, names=('e1', 'e2', 'e3', 'e4', 'e5',)); (e1, e2, e3, e4, e5,) = A._first_ngens(5)
>>> B = A.cdg_algebra({e5: e1*e2 + e3*e4})
>>> B.is_formal(Integer(1))
True
>>> B.is_formal(Integer(2))
False


ALGORITHM:

Apply the criteria in [Man2019] . Both the $$i$$-minimal model of the algebra and its cohomology algebra are computed. If the numerical invariants are different, the algebra is not $$i$$-formal.

If the numerical invariants match, the $$\psi$$ condition is checked.

minimal_model(i=3, max_iterations=3, partial_result=False)[source]#

Try to compute a map from a i-minimal gcda that is a i-quasi-isomorphism to self.

INPUT:

• i – integer (default: $$3$$); degree to which the result is required to induce an isomorphism in cohomology, and the domain is required to be minimal.

• max_iterations – integer (default: $$3$$); the number of iterations of the method at each degree. If the algorithm does not finish in this many iterations at each degree, an error is raised, or the partial result computed up to that point is returned, deppending on the partial_result flag.

• partial_result – boolean (default: False); wether to return the partial result if the max_iterations limit is reached.

OUTPUT:

A morphism from a minimal Sullivan (up to degree i) CDGA’s to self, that induces an isomorphism in cohomology up to degree i, and a monomorphism in degree i+1.

EXAMPLES:

sage: S.<x, y, z> = GradedCommutativeAlgebra(QQ, degrees = (1, 1, 2))
sage: d = S.differential({x:x*y, y:x*y})
sage: R = S.cdg_algebra(d)
sage: p = R.minimal_model()
sage: T = p.domain()
sage: p
with generators ('x1_0', 'x2_0') in degrees (1, 2)
over Rational Field with differential:
x1_0 --> 0
x2_0 --> 0
with generators ('x', 'y', 'z') in degrees (1, 1, 2)
over Rational Field with differential:
x --> x*y
y --> x*y
z --> 0
Defn: (x1_0, x2_0) --> (x - y, z)
sage: R.cohomology(1)
Free module generated by {[x - y]} over Rational Field
sage: T.cohomology(1)
Free module generated by {[x1_0]} over Rational Field
sage: [p(g.representative()) for g in T.cohomology(1).basis().keys()]
[x - y]
sage: R.cohomology(2)
Free module generated by {[z]} over Rational Field
sage: T.cohomology(2)
Free module generated by {[x2_0]} over Rational Field
sage: [p(g.representative()) for g in T.cohomology(2).basis().keys()]
[z]

sage: A.<e1, e2, e3, e4, e5, e6, e7> = GradedCommutativeAlgebra(QQ)
sage: d = A.differential({e1:e1*e7, e2:e2*e7, e3:-e3*e7, e4:-e4*e7})
sage: B = A.cdg_algebra(d)
sage: phi = B.minimal_model(i=3)
sage: M = phi.domain()
sage: M
Commutative Differential Graded Algebra with generators
('x1_0', 'x1_1', 'x1_2', 'x2_0', 'x2_1', 'x2_2', 'x2_3',
'y3_0', 'y3_1', 'y3_2', 'y3_3', 'y3_4', 'y3_5', 'y3_6', 'y3_7', 'y3_8')
in degrees (1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3)
over Rational Field with differential:
x1_0 --> 0
x1_1 --> 0
x1_2 --> 0
x2_0 --> 0
x2_1 --> 0
x2_2 --> 0
x2_3 --> 0
y3_0 --> x2_0^2
y3_1 --> x2_0*x2_1
y3_2 --> x2_1^2
y3_3 --> x2_0*x2_2
y3_4 --> x2_1*x2_2 + x2_0*x2_3
y3_5 --> x2_2^2
y3_6 --> x2_1*x2_3
y3_7 --> x2_2*x2_3
y3_8 --> x2_3^2

sage: phi
From: Commutative Differential Graded Algebra with generators
('x1_0', 'x1_1', 'x1_2', 'x2_0', 'x2_1', 'x2_2', 'x2_3',
'y3_0', 'y3_1', 'y3_2', 'y3_3', 'y3_4', 'y3_5', 'y3_6', 'y3_7', 'y3_8')
in degrees (1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3)
over Rational Field with differential:
x1_0 --> 0
x1_1 --> 0
x1_2 --> 0
x2_0 --> 0
x2_1 --> 0
x2_2 --> 0
x2_3 --> 0
y3_0 --> x2_0^2
y3_1 --> x2_0*x2_1
y3_2 --> x2_1^2
y3_3 --> x2_0*x2_2
y3_4 --> x2_1*x2_2 + x2_0*x2_3
y3_5 --> x2_2^2
y3_6 --> x2_1*x2_3
y3_7 --> x2_2*x2_3
y3_8 --> x2_3^2
To:   Commutative Differential Graded Algebra with generators
('e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7')
in degrees (1, 1, 1, 1, 1, 1, 1) over Rational Field with differential:
e1 --> e1*e7
e2 --> e2*e7
e3 --> -e3*e7
e4 --> -e4*e7
e5 --> 0
e6 --> 0
e7 --> 0
Defn: (x1_0, x1_1, x1_2, x2_0, x2_1, x2_2, x2_3,
y3_0, y3_1, y3_2, y3_3, y3_4, y3_5, y3_6, y3_7, y3_8)
--> (e5, e6, e7, e1*e3, e2*e3, e1*e4, e2*e4, 0, 0, 0, 0, 0, 0, 0, 0, 0)
sage: [B.cohomology(i).dimension() for i in [1..3]]
[3, 7, 13]
sage: [M.cohomology(i).dimension() for i in [1..3]]
[3, 7, 13]

>>> from sage.all import *
>>> S = GradedCommutativeAlgebra(QQ, degrees = (Integer(1), Integer(1), Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = S._first_ngens(3)
>>> d = S.differential({x:x*y, y:x*y})
>>> R = S.cdg_algebra(d)
>>> p = R.minimal_model()
>>> T = p.domain()
>>> p
with generators ('x1_0', 'x2_0') in degrees (1, 2)
over Rational Field with differential:
x1_0 --> 0
x2_0 --> 0
with generators ('x', 'y', 'z') in degrees (1, 1, 2)
over Rational Field with differential:
x --> x*y
y --> x*y
z --> 0
Defn: (x1_0, x2_0) --> (x - y, z)
>>> R.cohomology(Integer(1))
Free module generated by {[x - y]} over Rational Field
>>> T.cohomology(Integer(1))
Free module generated by {[x1_0]} over Rational Field
>>> [p(g.representative()) for g in T.cohomology(Integer(1)).basis().keys()]
[x - y]
>>> R.cohomology(Integer(2))
Free module generated by {[z]} over Rational Field
>>> T.cohomology(Integer(2))
Free module generated by {[x2_0]} over Rational Field
>>> [p(g.representative()) for g in T.cohomology(Integer(2)).basis().keys()]
[z]

>>> A = GradedCommutativeAlgebra(QQ, names=('e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7',)); (e1, e2, e3, e4, e5, e6, e7,) = A._first_ngens(7)
>>> d = A.differential({e1:e1*e7, e2:e2*e7, e3:-e3*e7, e4:-e4*e7})
>>> B = A.cdg_algebra(d)
>>> phi = B.minimal_model(i=Integer(3))
>>> M = phi.domain()
>>> M
Commutative Differential Graded Algebra with generators
('x1_0', 'x1_1', 'x1_2', 'x2_0', 'x2_1', 'x2_2', 'x2_3',
'y3_0', 'y3_1', 'y3_2', 'y3_3', 'y3_4', 'y3_5', 'y3_6', 'y3_7', 'y3_8')
in degrees (1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3)
over Rational Field with differential:
x1_0 --> 0
x1_1 --> 0
x1_2 --> 0
x2_0 --> 0
x2_1 --> 0
x2_2 --> 0
x2_3 --> 0
y3_0 --> x2_0^2
y3_1 --> x2_0*x2_1
y3_2 --> x2_1^2
y3_3 --> x2_0*x2_2
y3_4 --> x2_1*x2_2 + x2_0*x2_3
y3_5 --> x2_2^2
y3_6 --> x2_1*x2_3
y3_7 --> x2_2*x2_3
y3_8 --> x2_3^2

>>> phi
From: Commutative Differential Graded Algebra with generators
('x1_0', 'x1_1', 'x1_2', 'x2_0', 'x2_1', 'x2_2', 'x2_3',
'y3_0', 'y3_1', 'y3_2', 'y3_3', 'y3_4', 'y3_5', 'y3_6', 'y3_7', 'y3_8')
in degrees (1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3)
over Rational Field with differential:
x1_0 --> 0
x1_1 --> 0
x1_2 --> 0
x2_0 --> 0
x2_1 --> 0
x2_2 --> 0
x2_3 --> 0
y3_0 --> x2_0^2
y3_1 --> x2_0*x2_1
y3_2 --> x2_1^2
y3_3 --> x2_0*x2_2
y3_4 --> x2_1*x2_2 + x2_0*x2_3
y3_5 --> x2_2^2
y3_6 --> x2_1*x2_3
y3_7 --> x2_2*x2_3
y3_8 --> x2_3^2
To:   Commutative Differential Graded Algebra with generators
('e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7')
in degrees (1, 1, 1, 1, 1, 1, 1) over Rational Field with differential:
e1 --> e1*e7
e2 --> e2*e7
e3 --> -e3*e7
e4 --> -e4*e7
e5 --> 0
e6 --> 0
e7 --> 0
Defn: (x1_0, x1_1, x1_2, x2_0, x2_1, x2_2, x2_3,
y3_0, y3_1, y3_2, y3_3, y3_4, y3_5, y3_6, y3_7, y3_8)
--> (e5, e6, e7, e1*e3, e2*e3, e1*e4, e2*e4, 0, 0, 0, 0, 0, 0, 0, 0, 0)
>>> [B.cohomology(i).dimension() for i in (ellipsis_range(Integer(1),Ellipsis,Integer(3)))]
[3, 7, 13]
>>> [M.cohomology(i).dimension() for i in (ellipsis_range(Integer(1),Ellipsis,Integer(3)))]
[3, 7, 13]


ALGORITHM:

We follow the algorithm described in [Man2019]. It consists in constructing the minimal Sullivan algebra S by iteratively adding generators to it. Start with one closed generator of degree 1 for each element in the basis of the first cohomology of the algebra. Then proceed degree by degree. At each degree $$d$$, we keep adding generators of degree $$d-1$$ whose differential kills the elements in the kernel of the map $$H^d(S)\to H^d(self)$$. Once this map is made injective, we add the needed closed generators in degree $$d$$ to make it surjective.

Warning

The method is not granted to finish (it can’t, since the minimal model could be infinitely generated in some degrees). The parameter max_iterations controls how many iterations of the method are attempted at each degree. In case they are not enough, an exception is raised. If you think that the result will be finitely generated, you can try to run it again with a higher value for max_iterations.

REFERENCES:

numerical_invariants(max_degree=3, max_iterations=3)[source]#

Return the numerical invariants of the algebra, up to degree d. The numerical invariants reflect the number of generators added at each step of the construction of the minimal model.

The numerical invariants are the dimensions of the subsequent Hirsch extensions used at each degree to compute the minimal model.

INPUT:

• max_degree – integer (default: $$3$$); the degree up to which the numerical invariants are computed

• max_iterations – integer (default: $$3$$); the maximum number of iterations used to compute the minimal model, if it is not already cached

EXAMPLES:

sage: A.<e1, e2, e3> = GradedCommutativeAlgebra(QQ)
sage: B = A.cdg_algebra({e3 : e1*e2})
sage: B.minimal_model(4)
From: Commutative Differential Graded Algebra with
generators ('x1_0', 'x1_1', 'y1_0') in degrees (1, 1, 1)
over Rational Field with differential:
x1_0 --> 0
x1_1 --> 0
y1_0 --> x1_0*x1_1
To:   Commutative Differential Graded Algebra with
generators ('e1', 'e2', 'e3') in degrees (1, 1, 1)
over Rational Field with differential:
e1 --> 0
e2 --> 0
e3 --> e1*e2
Defn: (x1_0, x1_1, y1_0) --> (e1, e2, e3)
sage: B.numerical_invariants(2)
{1: [2, 1, 0], 2: [0, 0]}

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, names=('e1', 'e2', 'e3',)); (e1, e2, e3,) = A._first_ngens(3)
>>> B = A.cdg_algebra({e3 : e1*e2})
>>> B.minimal_model(Integer(4))
From: Commutative Differential Graded Algebra with
generators ('x1_0', 'x1_1', 'y1_0') in degrees (1, 1, 1)
over Rational Field with differential:
x1_0 --> 0
x1_1 --> 0
y1_0 --> x1_0*x1_1
To:   Commutative Differential Graded Algebra with
generators ('e1', 'e2', 'e3') in degrees (1, 1, 1)
over Rational Field with differential:
e1 --> 0
e2 --> 0
e3 --> e1*e2
Defn: (x1_0, x1_1, y1_0) --> (e1, e2, e3)
>>> B.numerical_invariants(Integer(2))
{1: [2, 1, 0], 2: [0, 0]}


ALGORITHM:

The numerical invariants are stored as the minimal model is constructed.

Warning

The method is not granted to finish (it can’t, since the minimal model could be infinitely generated in some degrees). The parameter max_iterations controls how many iterations of the method are attempted at each degree. In case they are not enough, an exception is raised. If you think that the result will be finitely generated, you can try to run it again with a higher value for max_iterations.

REFERENCES:

For a precise definition and properties, see [Man2019] .

quotient(I, check=True)[source]#

Create the quotient of this algebra by a two-sided ideal I.

INPUT:

• I – a two-sided homogeneous ideal of this algebra

• check – (default: True) if True, check whether I is generated by homogeneous elements

EXAMPLES:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1,1,2))
sage: B = A.cdg_algebra({y:x*y, z:x*z})
sage: B.inject_variables()
Defining x, y, z
sage: I = B.ideal([y*z])
sage: C = B.quotient(I)
sage: (y*z).differential()
2*x*y*z
sage: C((y*z).differential())
0
sage: C(y*z)
0

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1),Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> B = A.cdg_algebra({y:x*y, z:x*z})
>>> B.inject_variables()
Defining x, y, z
>>> I = B.ideal([y*z])
>>> C = B.quotient(I)
>>> (y*z).differential()
2*x*y*z
>>> C((y*z).differential())
0
>>> C(y*z)
0


It is checked that the differential maps the ideal into itself, to make sure that the quotient inherits a differential structure:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1,2,2))
sage: B = A.cdg_algebra({x:y})
sage: B.quotient(B.ideal(y*x))
Traceback (most recent call last):
...
ValueError: the differential does not preserve the ideal
sage: B.quotient(B.ideal(x))
Traceback (most recent call last):
...
ValueError: the differential does not preserve the ideal

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(2),Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> B = A.cdg_algebra({x:y})
>>> B.quotient(B.ideal(y*x))
Traceback (most recent call last):
...
ValueError: the differential does not preserve the ideal
>>> B.quotient(B.ideal(x))
Traceback (most recent call last):
...
ValueError: the differential does not preserve the ideal


INPUT:

• A – a commutative multi-graded algebra

• differential – a differential

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0, 1), (0,2)))
sage: B = A.cdg_algebra(differential={a: c})
sage: B.basis((1,0))
[a]
sage: B.basis(1, total=True)
[a, b]
sage: B.cohomology((1, 0))
Free module generated by {} over Rational Field
sage: B.cohomology(1, total=True)
Free module generated by {[b]} over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(0), Integer(1)), (Integer(0),Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> B = A.cdg_algebra(differential={a: c})
>>> B.basis((Integer(1),Integer(0)))
[a]
>>> B.basis(Integer(1), total=True)
[a, b]
>>> B.cohomology((Integer(1), Integer(0)))
Free module generated by {} over Rational Field
>>> B.cohomology(Integer(1), total=True)
Free module generated by {[b]} over Rational Field

class Element(A, rep)[source]#

Element class of a commutative differential multi-graded algebra.

coboundaries(n, total=False)[source]#

The n-th coboundary group of the algebra.

This is a vector space over the base field $$F$$, and it is returned as a subspace of the vector space $$F^d$$, where the n-th homogeneous component has dimension $$d$$.

INPUT:

• n – degree

• total (default False) – if True, return the coboundaries in total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0, 1), (0,2)))
sage: B = A.cdg_algebra(differential={a: c})
sage: B.coboundaries((0,2))
Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
sage: B.coboundaries(2)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(0), Integer(1)), (Integer(0),Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> B = A.cdg_algebra(differential={a: c})
>>> B.coboundaries((Integer(0),Integer(2)))
Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
>>> B.coboundaries(Integer(2))
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]

cocycles(n, total=False)[source]#

The n-th cocycle group of the algebra.

This is a vector space over the base field $$F$$, and it is returned as a subspace of the vector space $$F^d$$, where the n-th homogeneous component has dimension $$d$$.

INPUT:

• n – degree

• total – (default: False) if True, return the cocycles in total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0, 1), (0,2)))
sage: B = A.cdg_algebra(differential={a: c})
sage: B.cocycles((0,1))
Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
sage: B.cocycles((0,1), total=True)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(0), Integer(1)), (Integer(0),Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> B = A.cdg_algebra(differential={a: c})
>>> B.cocycles((Integer(0),Integer(1)))
Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
>>> B.cocycles((Integer(0),Integer(1)), total=True)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]

cohomology(n, total=False)[source]#

The n-th cohomology group of the algebra.

This is a vector space over the base ring, defined as the quotient cocycles/coboundaries. The elements of the quotient are lifted to the vector space of cocycles, and this is described in terms of those lifts.

Compare to cohomology_raw().

INPUT:

• n – degree

• total – (default: False) if True, return the cohomology in total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0, 1), (0,2)))
sage: B = A.cdg_algebra(differential={a: c})
sage: B.cohomology((0,2))
Free module generated by {} over Rational Field

sage: B.cohomology(1)
Free module generated by {[b]} over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(0), Integer(1)), (Integer(0),Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> B = A.cdg_algebra(differential={a: c})
>>> B.cohomology((Integer(0),Integer(2)))
Free module generated by {} over Rational Field

>>> B.cohomology(Integer(1))
Free module generated by {[b]} over Rational Field

cohomology_raw(n, total=False)[source]#

The n-th cohomology group of the algebra.

This is a vector space over the base ring, and it is returned as the quotient cocycles/coboundaries.

Compare to cohomology().

INPUT:

• n – degree

• total – (default: False) if True, return the cohomology in total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0, 1), (0,2)))
sage: B = A.cdg_algebra(differential={a: c})
sage: B.cohomology_raw((0,2))
Vector space quotient V/W of dimension 0 over Rational Field where
V: Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
W: Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]

sage: B.cohomology_raw(1)
Vector space quotient V/W of dimension 1 over Rational Field where
V: Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]
W: Vector space of degree 2 and dimension 0 over Rational Field
Basis matrix:
[]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(0), Integer(1)), (Integer(0),Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> B = A.cdg_algebra(differential={a: c})
>>> B.cohomology_raw((Integer(0),Integer(2)))
Vector space quotient V/W of dimension 0 over Rational Field where
V: Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
W: Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]

>>> B.cohomology_raw(Integer(1))
Vector space quotient V/W of dimension 1 over Rational Field where
V: Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]
W: Vector space of degree 2 and dimension 0 over Rational Field
Basis matrix:
[]

homology(n, total=False)[source]#

The n-th cohomology group of the algebra.

This is a vector space over the base ring, defined as the quotient cocycles/coboundaries. The elements of the quotient are lifted to the vector space of cocycles, and this is described in terms of those lifts.

Compare to cohomology_raw().

INPUT:

• n – degree

• total – (default: False) if True, return the cohomology in total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0, 1), (0,2)))
sage: B = A.cdg_algebra(differential={a: c})
sage: B.cohomology((0,2))
Free module generated by {} over Rational Field

sage: B.cohomology(1)
Free module generated by {[b]} over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(0), Integer(1)), (Integer(0),Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> B = A.cdg_algebra(differential={a: c})
>>> B.cohomology((Integer(0),Integer(2)))
Free module generated by {} over Rational Field

>>> B.cohomology(Integer(1))
Free module generated by {[b]} over Rational Field


Bases: Differential

Differential of a commutative multi-graded algebra.

coboundaries(n, total=False)[source]#

The n-th coboundary group of the algebra.

This is a vector space over the base field $$F$$, and it is returned as a subspace of the vector space $$F^d$$, where the n-th homogeneous component has dimension $$d$$.

INPUT:

• n – degree

• total (default False) – if True, return the coboundaries in total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1, 0), (0, 1), (0, 2)))
sage: d = A.differential({a: c})
sage: d.coboundaries((0, 2))
Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
sage: d.coboundaries(2)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1), Integer(0)), (Integer(0), Integer(1)), (Integer(0), Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> d = A.differential({a: c})
>>> d.coboundaries((Integer(0), Integer(2)))
Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
>>> d.coboundaries(Integer(2))
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]

cocycles(n, total=False)[source]#

The n-th cocycle group of the algebra.

This is a vector space over the base field $$F$$, and it is returned as a subspace of the vector space $$F^d$$, where the n-th homogeneous component has dimension $$d$$.

INPUT:

• n – degree

• total – (default: False) if True, return the cocycles in total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1, 0), (0, 1), (0, 2)))
sage: d = A.differential({a: c})
sage: d.cocycles((0, 1))
Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
sage: d.cocycles((0, 1), total=True)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1), Integer(0)), (Integer(0), Integer(1)), (Integer(0), Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> d = A.differential({a: c})
>>> d.cocycles((Integer(0), Integer(1)))
Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
>>> d.cocycles((Integer(0), Integer(1)), total=True)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]

cohomology(n, total=False)[source]#

The n-th cohomology group of the algebra.

This is a vector space over the base ring, defined as the quotient cocycles/coboundaries. The elements of the quotient are lifted to the vector space of cocycles, and this is described in terms of those lifts.

INPUT:

• n – degree

• total – (default: False) if True, return the cohomology in total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1, 0), (0, 1), (0, 2)))
sage: d = A.differential({a: c})
sage: d.cohomology((0, 2))
Free module generated by {} over Rational Field

sage: d.cohomology(1)
Free module generated by {[b]} over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1), Integer(0)), (Integer(0), Integer(1)), (Integer(0), Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> d = A.differential({a: c})
>>> d.cohomology((Integer(0), Integer(2)))
Free module generated by {} over Rational Field

>>> d.cohomology(Integer(1))
Free module generated by {[b]} over Rational Field

cohomology_raw(n, total=False)[source]#

The n-th cohomology group of the algebra.

This is a vector space over the base ring, and it is returned as the quotient cocycles/coboundaries.

INPUT:

• n – degree

• total – (default: False) if True, return the cohomology in total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1, 0), (0, 1), (0, 2)))
sage: d = A.differential({a: c})
sage: d.cohomology_raw((0, 2))
Vector space quotient V/W of dimension 0 over Rational Field where
V: Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
W: Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]

sage: d.cohomology_raw(1)
Vector space quotient V/W of dimension 1 over Rational Field where
V: Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]
W: Vector space of degree 2 and dimension 0 over Rational Field
Basis matrix:
[]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1), Integer(0)), (Integer(0), Integer(1)), (Integer(0), Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> d = A.differential({a: c})
>>> d.cohomology_raw((Integer(0), Integer(2)))
Vector space quotient V/W of dimension 0 over Rational Field where
V: Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]
W: Vector space of degree 1 and dimension 1 over Rational Field
Basis matrix:
[1]

>>> d.cohomology_raw(Integer(1))
Vector space quotient V/W of dimension 1 over Rational Field where
V: Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[0 1]
W: Vector space of degree 2 and dimension 0 over Rational Field
Basis matrix:
[]


The matrix that gives the differential in degree n.

Todo

Rename this to differential_matrix once inheritance, overriding, and cached methods work together better. See Issue #17201.

INPUT:

• n – degree

• total – (default: False) if True, return the matrix corresponding to total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1, 0), (0, 1), (0, 2)))
sage: d = A.differential({a: c})
[1]
[0 1]
[0 0]
[0 1]
[0 0]
[0 1]
[0 0]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1), Integer(0)), (Integer(0), Integer(1)), (Integer(0), Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> d = A.differential({a: c})
[1]
[0 1]
[0 0]
[0 1]
[0 0]
[0 1]
[0 0]

homology(n, total=False)[source]#

The n-th cohomology group of the algebra.

This is a vector space over the base ring, defined as the quotient cocycles/coboundaries. The elements of the quotient are lifted to the vector space of cocycles, and this is described in terms of those lifts.

INPUT:

• n – degree

• total – (default: False) if True, return the cohomology in total degree n

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1, 0), (0, 1), (0, 2)))
sage: d = A.differential({a: c})
sage: d.cohomology((0, 2))
Free module generated by {} over Rational Field

sage: d.cohomology(1)
Free module generated by {[b]} over Rational Field

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1), Integer(0)), (Integer(0), Integer(1)), (Integer(0), Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> d = A.differential({a: c})
>>> d.cohomology((Integer(0), Integer(2)))
Free module generated by {} over Rational Field

>>> d.cohomology(Integer(1))
Free module generated by {[b]} over Rational Field

class sage.algebras.commutative_dga.GCAlgebra(base, R=None, I=None, names=None, degrees=None, category=None)[source]#

INPUT:

• base – the base field

• names – (optional) names of the generators: a list of strings or a single string with the names separated by commas. If not specified, the generators are named “x0”, “x1”, …

• degrees – (optional) a tuple or list specifying the degrees of the generators; if omitted, each generator is given degree 1, and if both names and degrees are omitted, an error is raised.

• R (default: None) – the ring over which the algebra is defined: if this is specified, the algebra is defined to be R/I.

• I (default: None) – an ideal in R. It is should include, among other relations, the squares of the generators of odd degree

As described in the module-level documentation, these are graded algebras for which oddly graded elements anticommute and evenly graded elements commute.

The arguments R and I are primarily for use by the quotient() method.

These algebras should be graded over the integers; multi-graded algebras should be constructed using GCAlgebra_multigraded instead.

EXAMPLES:

sage: A.<a,b> = GradedCommutativeAlgebra(QQ, degrees = (2, 3))
sage: a.degree()
2
sage: B = A.quotient(A.ideal(a**2*b))
sage: B
Graded Commutative Algebra with generators ('a', 'b') in degrees (2, 3)
with relations [a^2*b] over Rational Field
sage: A.basis(7)
[a^2*b]
sage: B.basis(7)
[]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees = (Integer(2), Integer(3)), names=('a', 'b',)); (a, b,) = A._first_ngens(2)
>>> a.degree()
2
>>> B = A.quotient(A.ideal(a**Integer(2)*b))
>>> B
Graded Commutative Algebra with generators ('a', 'b') in degrees (2, 3)
with relations [a^2*b] over Rational Field
>>> A.basis(Integer(7))
[a^2*b]
>>> B.basis(Integer(7))
[]


Note that the function GradedCommutativeAlgebra() can also be used to construct these algebras.

class Element(A, rep)[source]#

An element of a graded commutative algebra.

basis_coefficients(total=False)[source]#

Return the coefficients of this homogeneous element with respect to the basis in its degree.

For example, if this is the sum of the 0th and 2nd basis elements, return the list [1, 0, 1].

Raise an error if the element is not homogeneous.

INPUT:

• total – boolean (default False); this is only used in the multi-graded case, in which case if True, it returns the coefficients with respect to the basis for the total degree of this element

OUTPUT:

A list of elements of the base field.

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(1, 2, 2, 3))
sage: A.basis(3)
[x*y, x*z, t]
sage: (t + 3*x*y).basis_coefficients()
[3, 0, 1]
sage: (t + x).basis_coefficients()
Traceback (most recent call last):
...
ValueError: this element is not homogeneous

sage: B.<c,d> = GradedCommutativeAlgebra(QQ, degrees=((2,0), (0,4)))
sage: B.basis(4)
[c^2, d]
sage: (c^2 - 1/2 * d).basis_coefficients(total=True)
[1, -1/2]
sage: (c^2 - 1/2 * d).basis_coefficients()
Traceback (most recent call last):
...
ValueError: this element is not homogeneous

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(2), Integer(2), Integer(3)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> A.basis(Integer(3))
[x*y, x*z, t]
>>> (t + Integer(3)*x*y).basis_coefficients()
[3, 0, 1]
>>> (t + x).basis_coefficients()
Traceback (most recent call last):
...
ValueError: this element is not homogeneous

>>> B = GradedCommutativeAlgebra(QQ, degrees=((Integer(2),Integer(0)), (Integer(0),Integer(4))), names=('c', 'd',)); (c, d,) = B._first_ngens(2)
>>> B.basis(Integer(4))
[c^2, d]
>>> (c**Integer(2) - Integer(1)/Integer(2) * d).basis_coefficients(total=True)
[1, -1/2]
>>> (c**Integer(2) - Integer(1)/Integer(2) * d).basis_coefficients()
Traceback (most recent call last):
...
ValueError: this element is not homogeneous

degree(total=False)[source]#

The degree of this element.

If the element is not homogeneous, this returns the maximum of the degrees of its monomials.

INPUT:

• total – ignored, present for compatibility with the multi-graded case

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(1, 2, 3, 3))
sage: el = z*t+2*x*y-y^2*z
sage: el.degree()
7
sage: el.monomials()
[y^2*z, z*t, x*y]
sage: [i.degree() for i in el.monomials()]
[7, 6, 3]

sage: A(0).degree()
Traceback (most recent call last):
...
ValueError: the zero element does not have a well-defined degree

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(2), Integer(3), Integer(3)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> el = z*t+Integer(2)*x*y-y**Integer(2)*z
>>> el.degree()
7
>>> el.monomials()
[y^2*z, z*t, x*y]
>>> [i.degree() for i in el.monomials()]
[7, 6, 3]

>>> A(Integer(0)).degree()
Traceback (most recent call last):
...
ValueError: the zero element does not have a well-defined degree

dict()[source]#

A dictionary that determines the element.

The keys of this dictionary are the tuples of exponents of each monomial, and the values are the corresponding coefficients.

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(1, 2, 2, 3))
sage: dic = (x*y - 5*y*z + 7*x*y^2*z^3*t).dict()
sage: sorted(dic.items())
[((0, 1, 1, 0), -5), ((1, 1, 0, 0), 1), ((1, 2, 3, 1), 7)]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(2), Integer(2), Integer(3)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> dic = (x*y - Integer(5)*y*z + Integer(7)*x*y**Integer(2)*z**Integer(3)*t).dict()
>>> sorted(dic.items())
[((0, 1, 1, 0), -5), ((1, 1, 0, 0), 1), ((1, 2, 3, 1), 7)]

homogeneous_parts()[source]#

Return the homogeneous parts of the element. The result is given as a dictionary indexed by degree.

EXAMPLES:

sage: A.<e1,e2,e3,e4,e5> = GradedCommutativeAlgebra(QQ)
sage: a = e1*e3*e5-3*e2*e3*e5 + e1*e2 -2*e3 + e5
sage: a.homogeneous_parts()
{1: -2*e3 + e5, 2: e1*e2, 3: e1*e3*e5 - 3*e2*e3*e5}

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, names=('e1', 'e2', 'e3', 'e4', 'e5',)); (e1, e2, e3, e4, e5,) = A._first_ngens(5)
>>> a = e1*e3*e5-Integer(3)*e2*e3*e5 + e1*e2 -Integer(2)*e3 + e5
>>> a.homogeneous_parts()
{1: -2*e3 + e5, 2: e1*e2, 3: e1*e3*e5 - 3*e2*e3*e5}

is_homogeneous(total=False)[source]#

Return True if self is homogeneous and False otherwise.

INPUT:

• total – boolean (default False); only used in the multi-graded case, in which case if True, check to see if self is homogeneous with respect to total degree

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(1, 2, 3, 3))
sage: el = z*t + 2*x*y - y^2*z
sage: el.degree()
7
sage: el.monomials()
[y^2*z, z*t, x*y]
sage: [i.degree() for i in el.monomials()]
[7, 6, 3]
sage: el.is_homogeneous()
False
sage: em = y^3 - 5*z*t + 3/2*x*y*t
sage: em.is_homogeneous()
True
sage: em.monomials()
[y^3, x*y*t, z*t]
sage: [i.degree() for i in em.monomials()]
[6, 6, 6]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(2), Integer(3), Integer(3)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> el = z*t + Integer(2)*x*y - y**Integer(2)*z
>>> el.degree()
7
>>> el.monomials()
[y^2*z, z*t, x*y]
>>> [i.degree() for i in el.monomials()]
[7, 6, 3]
>>> el.is_homogeneous()
False
>>> em = y**Integer(3) - Integer(5)*z*t + Integer(3)/Integer(2)*x*y*t
>>> em.is_homogeneous()
True
>>> em.monomials()
[y^3, x*y*t, z*t]
>>> [i.degree() for i in em.monomials()]
[6, 6, 6]


The element 0 is homogeneous, even though it doesn’t have a well-defined degree:

sage: A(0).is_homogeneous()
True

>>> from sage.all import *
>>> A(Integer(0)).is_homogeneous()
True


sage: B.<c,d> = GradedCommutativeAlgebra(QQ, degrees=((2, 0), (0, 4)))
sage: (c^2 - 1/2 * d).is_homogeneous()
False
sage: (c^2 - 1/2 * d).is_homogeneous(total=True)
True

>>> from sage.all import *
>>> B = GradedCommutativeAlgebra(QQ, degrees=((Integer(2), Integer(0)), (Integer(0), Integer(4))), names=('c', 'd',)); (c, d,) = B._first_ngens(2)
>>> (c**Integer(2) - Integer(1)/Integer(2) * d).is_homogeneous()
False
>>> (c**Integer(2) - Integer(1)/Integer(2) * d).is_homogeneous(total=True)
True

basis(n)[source]#

Return a basis of the n-th homogeneous component of self.

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, degrees=(1, 2, 2, 3))
sage: A.basis(2)
[y, z]
sage: A.basis(3)
[x*y, x*z, t]
sage: A.basis(4)
[y^2, y*z, z^2, x*t]
sage: A.basis(5)
[x*y^2, x*y*z, x*z^2, y*t, z*t]
sage: A.basis(6)
[y^3, y^2*z, y*z^2, z^3, x*y*t, x*z*t]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(2), Integer(2), Integer(3)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> A.basis(Integer(2))
[y, z]
>>> A.basis(Integer(3))
[x*y, x*z, t]
>>> A.basis(Integer(4))
[y^2, y*z, z^2, x*t]
>>> A.basis(Integer(5))
[x*y^2, x*y*z, x*z^2, y*t, z*t]
>>> A.basis(Integer(6))
[y^3, y^2*z, y*z^2, z^3, x*y*t, x*z*t]

cdg_algebra(differential)[source]#

Construct a differential graded commutative algebra from self by specifying a differential.

INPUT:

• differential – a dictionary defining a differential or a map defining a valid differential

The keys of the dictionary are generators of the algebra, and the associated values are their targets under the differential. Any generators which are not specified are assumed to have zero differential. Alternatively, the differential can be defined using the differential() method; see below for an example.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 1))
sage: B = A.cdg_algebra({a: b*c, b: a*c})
sage: B
Commutative Differential Graded Algebra with generators ('a', 'b', 'c')
in degrees (1, 1, 1) over Rational Field with differential:
a --> b*c
b --> a*c
c --> 0

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(1), Integer(1)), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> B = A.cdg_algebra({a: b*c, b: a*c})
>>> B
Commutative Differential Graded Algebra with generators ('a', 'b', 'c')
in degrees (1, 1, 1) over Rational Field with differential:
a --> b*c
b --> a*c
c --> 0


Note that differential can also be a map:

sage: d = A.differential({a: b*c, b: a*c})
sage: d
Differential of Graded Commutative Algebra with generators ('a', 'b', 'c')
in degrees (1, 1, 1) over Rational Field
Defn: a --> b*c
b --> a*c
c --> 0
sage: A.cdg_algebra(d) is B
True

>>> from sage.all import *
>>> d = A.differential({a: b*c, b: a*c})
>>> d
Differential of Graded Commutative Algebra with generators ('a', 'b', 'c')
in degrees (1, 1, 1) over Rational Field
Defn: a --> b*c
b --> a*c
c --> 0
>>> A.cdg_algebra(d) is B
True

differential(diff)[source]#

Construct a differential on self.

INPUT:

• diff – a dictionary defining a differential

The keys of the dictionary are generators of the algebra, and the associated values are their targets under the differential. Any generators which are not specified are assumed to have zero differential.

EXAMPLES:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 2))
sage: A.differential({y:x*y, x: x*y})
Differential of Graded Commutative Algebra with generators ('x', 'y', 'z')
in degrees (1, 1, 2) over Rational Field
Defn: x --> x*y
y --> x*y
z --> 0
sage: B.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=(1, 2, 2))
sage: d = B.differential({b:a*c, c:a*c})
sage: d(b*c)
a*b*c + a*c^2

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(1), Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> A.differential({y:x*y, x: x*y})
Differential of Graded Commutative Algebra with generators ('x', 'y', 'z')
in degrees (1, 1, 2) over Rational Field
Defn: x --> x*y
y --> x*y
z --> 0
>>> B = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(2), Integer(2)), names=('a', 'b', 'c',)); (a, b, c,) = B._first_ngens(3)
>>> d = B.differential({b:a*c, c:a*c})
>>> d(b*c)
a*b*c + a*c^2

quotient(I, check=True)[source]#

Create the quotient of this algebra by a two-sided ideal I.

INPUT:

• I – a two-sided homogeneous ideal of this algebra

• check – (default: True) if True, check whether I is generated by homogeneous elements

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(GF(5), degrees=(2, 2, 3, 4))
sage: I = A.ideal([x*t+z^2, x*y - t])
sage: B = A.quotient(I); B
Graded Commutative Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 2, 3, 4) with relations [x*t, x*y - t]
over Finite Field of size 5
sage: B(x*t)
0
sage: B(x*y)
t
sage: A.basis(7)
[x^2*z, x*y*z, y^2*z, z*t]
sage: B.basis(7)
[x^2*z, y^2*z, z*t]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(GF(Integer(5)), degrees=(Integer(2), Integer(2), Integer(3), Integer(4)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> I = A.ideal([x*t+z**Integer(2), x*y - t])
>>> B = A.quotient(I); B
Graded Commutative Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 2, 3, 4) with relations [x*t, x*y - t]
over Finite Field of size 5
>>> B(x*t)
0
>>> B(x*y)
t
>>> A.basis(Integer(7))
[x^2*z, x*y*z, y^2*z, z*t]
>>> B.basis(Integer(7))
[x^2*z, y^2*z, z*t]

class sage.algebras.commutative_dga.GCAlgebraHomset(R, S, category=None)[source]#

Set of morphisms between two graded commutative algebras.

Note

Homsets (and thus morphisms) have only been implemented when the base fields are the same for the domain and codomain.

EXAMPLES:

sage: A.<x,y> = GradedCommutativeAlgebra(QQ, degrees=(1,2))
sage: H = Hom(A,A)
sage: H([x,y]) == H.identity()
True
sage: H([x,x]) == H.identity()
False

sage: H = Hom(A,B)
sage: H([y,0])
From: Graded Commutative Algebra with generators ('w', 'x')
in degrees (1, 2) over Rational Field
To:   Graded Commutative Algebra with generators ('y', 'z')
in degrees (1, 1) over Rational Field
Defn: (w, x) --> (y, 0)
sage: H([y,y*z])
From: Graded Commutative Algebra with generators ('w', 'x')
in degrees (1, 2) over Rational Field
To:   Graded Commutative Algebra with generators ('y', 'z')
in degrees (1, 1) over Rational Field
Defn: (w, x) --> (y, y*z)

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(2)), names=('x', 'y',)); (x, y,) = A._first_ngens(2)
>>> H = Hom(A,A)
>>> H([x,y]) == H.identity()
True
>>> H([x,x]) == H.identity()
False

>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(2)), names=('w', 'x',)); (w, x,) = A._first_ngens(2)
>>> B = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1)), names=('y', 'z',)); (y, z,) = B._first_ngens(2)
>>> H = Hom(A,B)
>>> H([y,Integer(0)])
From: Graded Commutative Algebra with generators ('w', 'x')
in degrees (1, 2) over Rational Field
To:   Graded Commutative Algebra with generators ('y', 'z')
in degrees (1, 1) over Rational Field
Defn: (w, x) --> (y, 0)
>>> H([y,y*z])
From: Graded Commutative Algebra with generators ('w', 'x')
in degrees (1, 2) over Rational Field
To:   Graded Commutative Algebra with generators ('y', 'z')
in degrees (1, 1) over Rational Field
Defn: (w, x) --> (y, y*z)

identity()[source]#

Construct the identity morphism of this homset.

EXAMPLES:

sage: A.<x,y> = GradedCommutativeAlgebra(QQ, degrees=(1,2))
sage: H = Hom(A,A)
sage: H([x,y]) == H.identity()
True
sage: H([x,x]) == H.identity()
False

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(2)), names=('x', 'y',)); (x, y,) = A._first_ngens(2)
>>> H = Hom(A,A)
>>> H([x,y]) == H.identity()
True
>>> H([x,x]) == H.identity()
False

zero()[source]#

Construct the “zero” morphism of this homset: the map sending each generator to zero.

EXAMPLES:

sage: A.<x,y> = GradedCommutativeAlgebra(QQ, degrees=(1,2))
sage: zero = Hom(A,B).zero()
sage: zero(x) == zero(y) == 0
True

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(2)), names=('x', 'y',)); (x, y,) = A._first_ngens(2)
>>> B = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1),Integer(1)), names=('a', 'b', 'c',)); (a, b, c,) = B._first_ngens(3)
>>> zero = Hom(A,B).zero()
>>> zero(x) == zero(y) == Integer(0)
True

class sage.algebras.commutative_dga.GCAlgebraMorphism(parent, im_gens, check=True)[source]#

Create a morphism between two graded commutative algebras.

INPUT:

• parent – the parent homset

• im_gens – the images, in the codomain, of the generators of the domain

• check – boolean (default: True); check whether the proposed map is actually an algebra map; if the domain and codomain have differentials, also check that the map respects those.

EXAMPLES:

sage: A.<x,y> = GradedCommutativeAlgebra(QQ)
sage: H = Hom(A,A)
sage: f = H([y,x])
sage: f
with generators ('x', 'y') in degrees (1, 1) over Rational Field
Defn: (x, y) --> (y, x)
sage: f(x*y)
-x*y

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, names=('x', 'y',)); (x, y,) = A._first_ngens(2)
>>> H = Hom(A,A)
>>> f = H([y,x])
>>> f
with generators ('x', 'y') in degrees (1, 1) over Rational Field
Defn: (x, y) --> (y, x)
>>> f(x*y)
-x*y


Return True if this morphism is graded.

That is, return True if $$f(x)$$ is zero, or if $$f(x)$$ is homogeneous and has the same degree as $$x$$, for each generator $$x$$.

INPUT:

• total (default: False) – if True, use the total degree to determine whether the morphism is graded (relevant only in the multigraded case)

EXAMPLES:

sage: C.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=(1,1,2))
sage: H = Hom(C,C)
sage: H([a, b, a*b + 2*a]).is_graded()
False
True

sage: A.<w,x> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (1,0)))
sage: B.<y,z> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0,1)))
sage: H = Hom(A,B)
True
False
True

>>> from sage.all import *
>>> C = GradedCommutativeAlgebra(QQ, degrees=(Integer(1),Integer(1),Integer(2)), names=('a', 'b', 'c',)); (a, b, c,) = C._first_ngens(3)
>>> H = Hom(C,C)
>>> H([a, b, a*b + Integer(2)*a]).is_graded()
False
True

>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(1),Integer(0))), names=('w', 'x',)); (w, x,) = A._first_ngens(2)
>>> B = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(0),Integer(1))), names=('y', 'z',)); (y, z,) = B._first_ngens(2)
>>> H = Hom(A,B)
True
False
True

class sage.algebras.commutative_dga.GCAlgebra_multigraded(base, degrees, names=None, R=None, I=None, category=None)[source]#

Bases: GCAlgebra

INPUT:

• base – the base field

• degrees – a tuple or list specifying the degrees of the generators

• names – (optional) names of the generators: a list of strings or a single string with the names separated by commas; if not specified, the generators are named x0, x1, …

• R – (optional) the ring over which the algebra is defined

• I – (optional) an ideal in R; it should include, among other relations, the squares of the generators of odd degree

When defining such an algebra, each entry of degrees should be a list, tuple, or element of an additive (free) abelian group. Regardless of how the user specifies the degrees, Sage converts them to group elements.

The arguments R and I are primarily for use by the GCAlgebra.quotient() method.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0,1), (1,1)))
sage: A
Graded Commutative Algebra with generators ('a', 'b', 'c')
in degrees ((1, 0), (0, 1), (1, 1)) over Rational Field
sage: a**2
0
sage: c.degree(total=True)
2
sage: c**2
c^2
sage: c.degree()
(1, 1)

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(0),Integer(1)), (Integer(1),Integer(1))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> A
Graded Commutative Algebra with generators ('a', 'b', 'c')
in degrees ((1, 0), (0, 1), (1, 1)) over Rational Field
>>> a**Integer(2)
0
>>> c.degree(total=True)
2
>>> c**Integer(2)
c^2
>>> c.degree()
(1, 1)


Although the degree of c was defined using a Python tuple, it is returned as an element of an additive abelian group, and so it can be manipulated via arithmetic operations:

sage: type(c.degree())
sage: 2 * c.degree()
(2, 2)
sage: (a*b).degree() == a.degree() + b.degree()
True

>>> from sage.all import *
>>> type(c.degree())
>>> Integer(2) * c.degree()
(2, 2)
>>> (a*b).degree() == a.degree() + b.degree()
True


The basis() method and the Element.degree() method both accept the boolean keyword total. If True, use the total degree:

sage: A.basis(2, total=True)
[a*b, c]
sage: c.degree(total=True)
2

>>> from sage.all import *
>>> A.basis(Integer(2), total=True)
[a*b, c]
>>> c.degree(total=True)
2

class Element(A, rep)[source]#

Bases: Element

degree(total=False)[source]#

Return the degree of this element.

INPUT:

• total – if True, return the total degree, an integer; otherwise, return the degree as an element of an additive free abelian group

If not requesting the total degree, raise an error if the element is not homogeneous.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(GF(2),
....:                                      degrees=((1,0), (0,1), (1,1)))
sage: (a**2*b).degree()
(2, 1)
sage: (a**2*b).degree(total=True)
3
sage: (a**2*b + c).degree()
Traceback (most recent call last):
...
ValueError: this element is not homogeneous
sage: (a**2*b + c).degree(total=True)
3
sage: A(0).degree()
Traceback (most recent call last):
...
ValueError: the zero element does not have a well-defined degree

>>> from sage.all import *
...                                      degrees=((Integer(1),Integer(0)), (Integer(0),Integer(1)), (Integer(1),Integer(1))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> (a**Integer(2)*b).degree()
(2, 1)
>>> (a**Integer(2)*b).degree(total=True)
3
>>> (a**Integer(2)*b + c).degree()
Traceback (most recent call last):
...
ValueError: this element is not homogeneous
>>> (a**Integer(2)*b + c).degree(total=True)
3
>>> A(Integer(0)).degree()
Traceback (most recent call last):
...
ValueError: the zero element does not have a well-defined degree

basis(n, total=False)[source]#

Basis in degree n.

• n – degree or integer

• total (default: False) – if True, return the basis in total degree n.

If n is an integer rather than a multi-index, then the total degree is used in that case as well.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(GF(2), degrees=((1,0), (0,1), (1,1)))
sage: A.basis((1,1))
[a*b, c]
sage: A.basis(2, total=True)
[a^2, a*b, b^2, c]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(GF(Integer(2)), degrees=((Integer(1),Integer(0)), (Integer(0),Integer(1)), (Integer(1),Integer(1))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> A.basis((Integer(1),Integer(1)))
[a*b, c]
>>> A.basis(Integer(2), total=True)
[a^2, a*b, b^2, c]


Since 2 is a not a multi-index, we don’t need to specify total=True:

sage: A.basis(2)
[a^2, a*b, b^2, c]

>>> from sage.all import *
>>> A.basis(Integer(2))
[a^2, a*b, b^2, c]


If total==True, then n can still be a tuple, list, etc., and its total degree is used instead:

sage: A.basis((1,1), total=True)
[a^2, a*b, b^2, c]

>>> from sage.all import *
>>> A.basis((Integer(1),Integer(1)), total=True)
[a^2, a*b, b^2, c]

cdg_algebra(differential)[source]#

Construct a differential graded commutative algebra from self by specifying a differential.

INPUT:

• differential – a dictionary defining a differential or a map defining a valid differential

The keys of the dictionary are generators of the algebra, and the associated values are their targets under the differential. Any generators which are not specified are assumed to have zero differential. Alternatively, the differential can be defined using the differential() method; see below for an example.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0, 1), (0,2)))
sage: A.cdg_algebra({a: c})
Commutative Differential Graded Algebra with generators ('a', 'b', 'c')
in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field with differential:
a --> c
b --> 0
c --> 0
sage: d = A.differential({a: c})
sage: A.cdg_algebra(d)
Commutative Differential Graded Algebra with generators ('a', 'b', 'c')
in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field with differential:
a --> c
b --> 0
c --> 0

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(0), Integer(1)), (Integer(0),Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> A.cdg_algebra({a: c})
Commutative Differential Graded Algebra with generators ('a', 'b', 'c')
in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field with differential:
a --> c
b --> 0
c --> 0
>>> d = A.differential({a: c})
>>> A.cdg_algebra(d)
Commutative Differential Graded Algebra with generators ('a', 'b', 'c')
in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field with differential:
a --> c
b --> 0
c --> 0

differential(diff)[source]#

Construct a differential on self.

INPUT:

• diff – a dictionary defining a differential

The keys of the dictionary are generators of the algebra, and the associated values are their targets under the differential. Any generators which are not specified are assumed to have zero differential.

EXAMPLES:

sage: A.<a,b,c> = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0, 1), (0,2)))
sage: A.differential({a: c})
Differential of Graded Commutative Algebra with generators ('a', 'b', 'c')
in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field
Defn: a --> c
b --> 0
c --> 0

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=((Integer(1),Integer(0)), (Integer(0), Integer(1)), (Integer(0),Integer(2))), names=('a', 'b', 'c',)); (a, b, c,) = A._first_ngens(3)
>>> A.differential({a: c})
Differential of Graded Commutative Algebra with generators ('a', 'b', 'c')
in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field
Defn: a --> c
b --> 0
c --> 0

quotient(I, check=True)[source]#

Create the quotient of this algebra by a two-sided ideal I.

INPUT:

• I – a two-sided homogeneous ideal of this algebra

• check – (default: True) if True, check whether I is generated by homogeneous elements

EXAMPLES:

sage: A.<x,y,z,t> = GradedCommutativeAlgebra(GF(5), degrees=(2, 2, 3, 4))
sage: I = A.ideal([x*t+z^2, x*y - t])
sage: B = A.quotient(I)
sage: B
Graded Commutative Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 2, 3, 4) with relations [x*t, x*y - t]
over Finite Field of size 5
sage: B(x*t)
0
sage: B(x*y)
t
sage: A.basis(7)
[x^2*z, x*y*z, y^2*z, z*t]
sage: B.basis(7)
[x^2*z, y^2*z, z*t]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(GF(Integer(5)), degrees=(Integer(2), Integer(2), Integer(3), Integer(4)), names=('x', 'y', 'z', 't',)); (x, y, z, t,) = A._first_ngens(4)
>>> I = A.ideal([x*t+z**Integer(2), x*y - t])
>>> B = A.quotient(I)
>>> B
Graded Commutative Algebra with generators ('x', 'y', 'z', 't')
in degrees (2, 2, 3, 4) with relations [x*t, x*y - t]
over Finite Field of size 5
>>> B(x*t)
0
>>> B(x*y)
t
>>> A.basis(Integer(7))
[x^2*z, x*y*z, y^2*z, z*t]
>>> B.basis(Integer(7))
[x^2*z, y^2*z, z*t]


INPUT:

There are two ways to call this. The first way defines a free graded commutative algebra:

• ring – the base field over which to work

• names – names of the generators. You may also use Sage’s A.<x,y,...> = ... syntax to define the names. If no names are specified, the generators are named x0, x1, …

• degrees – degrees of the generators; if this is omitted, the degree of each generator is 1, and if both names and degrees are omitted, an error is raised

• max_degree – the maximal degree of the graded algebra. If omitted, no maximal degree is assumed and an instance of GCAlgebra is returned. Otherwise, an instance of sage.algebras.commutative_graded_algebra.GradedCommutativeAlgebraWithMaxDeg is created.

Once such an algebra has been defined, one can use its associated methods to take a quotient, impose a differential, etc. See the examples below.

The second way takes a graded commutative algebra and imposes relations:

• ring – a graded commutative algebra

• relations – a list or tuple of elements of ring

EXAMPLES:

sage: GradedCommutativeAlgebra(QQ, 'x, y, z')
Graded Commutative Algebra with generators ('x', 'y', 'z')
in degrees (1, 1, 1) over Rational Field
Graded Commutative Algebra with generators ('x0', 'x1', 'x2')
in degrees (2, 3, 4) over Rational Field

>>> from sage.all import *
Graded Commutative Algebra with generators ('x', 'y', 'z')
in degrees (1, 1, 1) over Rational Field
Graded Commutative Algebra with generators ('x0', 'x1', 'x2')
in degrees (2, 3, 4) over Rational Field


As usual in Sage, the A.<...> notation defines both the algebra and the generator names:

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 2))
sage: x^2
0
sage: y*x #  Odd classes anticommute.
-x*y
sage: z*y  # z is central since it is in degree 2.
y*z
sage: (x*y*z**3).degree()
8
sage: A.basis(3)  # basis of homogeneous degree 3 elements
[x*z, y*z]

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(1), Integer(1), Integer(2)), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> x**Integer(2)
0
>>> y*x #  Odd classes anticommute.
-x*y
>>> z*y  # z is central since it is in degree 2.
y*z
>>> (x*y*z**Integer(3)).degree()
8
>>> A.basis(Integer(3))  # basis of homogeneous degree 3 elements
[x*z, y*z]


Defining a quotient:

sage: I = A.ideal(x*z)
sage: AQ = A.quotient(I); AQ
Graded Commutative Algebra with generators ('x', 'y', 'z')
in degrees (1, 1, 2) with relations [x*z] over Rational Field
sage: AQ.basis(3)
[y*z]

>>> from sage.all import *
>>> I = A.ideal(x*z)
>>> AQ = A.quotient(I); AQ
Graded Commutative Algebra with generators ('x', 'y', 'z')
in degrees (1, 1, 2) with relations [x*z] over Rational Field
>>> AQ.basis(Integer(3))
[y*z]


Note that AQ has no specified differential. This is reflected in its print representation: AQ is described as a “graded commutative algebra” – the word “differential” is missing. Also, it has no default differential:

sage: AQ.differential()
Traceback (most recent call last):
...
TypeError: ...differential() missing 1 required positional argument:
'diff'

>>> from sage.all import *
>>> AQ.differential()
Traceback (most recent call last):
...
TypeError: ...differential() missing 1 required positional argument:
'diff'


Now we add a differential to AQ:

sage: B = AQ.cdg_algebra({z: y*z}); B
Commutative Differential Graded Algebra with generators ('x', 'y', 'z')
in degrees (1, 1, 2) with relations [x*z] over Rational Field with differential:
x --> 0
y --> 0
z --> y*z
sage: B.differential()
Differential of Commutative Differential Graded Algebra with generators
('x', 'y', 'z') in degrees (1, 1, 2) with relations [x*z] over Rational Field
Defn: x --> 0
y --> 0
z --> y*z
sage: B.cohomology(1)
Free module generated by {[x], [y]} over Rational Field
sage: B.cohomology(2)
Free module generated by {[x*y]} over Rational Field

>>> from sage.all import *
>>> B = AQ.cdg_algebra({z: y*z}); B
Commutative Differential Graded Algebra with generators ('x', 'y', 'z')
in degrees (1, 1, 2) with relations [x*z] over Rational Field with differential:
x --> 0
y --> 0
z --> y*z
>>> B.differential()
Differential of Commutative Differential Graded Algebra with generators
('x', 'y', 'z') in degrees (1, 1, 2) with relations [x*z] over Rational Field
Defn: x --> 0
y --> 0
z --> y*z
>>> B.cohomology(Integer(1))
Free module generated by {[x], [y]} over Rational Field
>>> B.cohomology(Integer(2))
Free module generated by {[x*y]} over Rational Field


We compute algebra generators for cohomology in a range of degrees. This cohomology algebra appears to be finitely generated:

sage: B.cohomology_generators(15)
{1: [x, y]}

>>> from sage.all import *
>>> B.cohomology_generators(Integer(15))
{1: [x, y]}


We can construct multi-graded rings as well. We work in characteristic 2 for a change, so the algebras here are honestly commutative:

sage: C.<a,b,c,d> = GradedCommutativeAlgebra(GF(2),
....:                                        degrees=((1,0), (1,1), (0,2), (0,3)))
sage: D = C.cdg_algebra(differential={a: c, b: d}); D
Commutative Differential Graded Algebra with generators ('a', 'b', 'c', 'd')
in degrees ((1, 0), (1, 1), (0, 2), (0, 3)) over Finite Field of size 2
with differential:
a --> c
b --> d
c --> 0
d --> 0

>>> from sage.all import *
...                                        degrees=((Integer(1),Integer(0)), (Integer(1),Integer(1)), (Integer(0),Integer(2)), (Integer(0),Integer(3))), names=('a', 'b', 'c', 'd',)); (a, b, c, d,) = C._first_ngens(4)
>>> D = C.cdg_algebra(differential={a: c, b: d}); D
Commutative Differential Graded Algebra with generators ('a', 'b', 'c', 'd')
in degrees ((1, 0), (1, 1), (0, 2), (0, 3)) over Finite Field of size 2
with differential:
a --> c
b --> d
c --> 0
d --> 0


We can examine D using both total degrees and multidegrees. Use tuples, lists, vectors, or elements of additive abelian groups to specify degrees:

sage: D.basis(3)      # basis in total degree 3
[a^3, a*b, a*c, d]
sage: D.basis((1,2))  # basis in degree (1,2)
[a*c]
sage: D.basis([1,2])
[a*c]
sage: D.basis(vector([1,2]))
[a*c]
Additive abelian group isomorphic to Z + Z
sage: D.basis(G(vector([1,2])))
[a*c]

>>> from sage.all import *
>>> D.basis(Integer(3))      # basis in total degree 3
[a^3, a*b, a*c, d]
>>> D.basis((Integer(1),Integer(2)))  # basis in degree (1,2)
[a*c]
>>> D.basis([Integer(1),Integer(2)])
[a*c]
>>> D.basis(vector([Integer(1),Integer(2)]))
[a*c]
Additive abelian group isomorphic to Z + Z
>>> D.basis(G(vector([Integer(1),Integer(2)])))
[a*c]


At this point, a, for example, is an element of C. We can redefine it so that it is instead an element of D in several ways, for instance using gens() method:

sage: a, b, c, d = D.gens()
sage: a.differential()
c

>>> from sage.all import *
>>> a, b, c, d = D.gens()
>>> a.differential()
c


Or the inject_variables() method:

sage: D.inject_variables()
Defining a, b, c, d
sage: (a*b).differential()
b*c + a*d
sage: (a*b*c**2).degree()
(2, 5)

>>> from sage.all import *
>>> D.inject_variables()
Defining a, b, c, d
>>> (a*b).differential()
b*c + a*d
>>> (a*b*c**Integer(2)).degree()
(2, 5)


Degrees are returned as elements of additive abelian groups:

sage: (a*b*c**2).degree() in G
True

sage: (a*b*c**2).degree(total=True)  # total degree
7
sage: D.cohomology(4)
Free module generated by {[a^4], [b^2]} over Finite Field of size 2
sage: D.cohomology((2,2))
Free module generated by {[b^2]} over Finite Field of size 2

>>> from sage.all import *
>>> (a*b*c**Integer(2)).degree() in G
True

>>> (a*b*c**Integer(2)).degree(total=True)  # total degree
7
>>> D.cohomology(Integer(4))
Free module generated by {[a^4], [b^2]} over Finite Field of size 2
>>> D.cohomology((Integer(2),Integer(2)))
Free module generated by {[b^2]} over Finite Field of size 2


sage: A.<p,e> = GradedCommutativeAlgebra(QQ, degrees=(4,2), max_degree=6); A
Graded commutative algebra with generators ('p', 'e') in degrees (4, 2)
with maximal degree 6
sage: p^2
0

>>> from sage.all import *
>>> A = GradedCommutativeAlgebra(QQ, degrees=(Integer(4),Integer(2)), max_degree=Integer(6), names=('p', 'e',)); (p, e,) = A._first_ngens(2); A
Graded commutative algebra with generators ('p', 'e') in degrees (4, 2)
with maximal degree 6
>>> p**Integer(2)
0

sage.algebras.commutative_dga.exterior_algebra_basis(degrees)[source]#

Basis of an exterior algebra in degree n, where the generators are in degrees degrees.

INPUT:

• n – integer

• degrees – iterable of integers

Return list of lists, each list representing exponents for the corresponding generators. (So each list consists of 0’s and 1’s.)

EXAMPLES:

sage: from sage.algebras.commutative_dga import exterior_algebra_basis
sage: exterior_algebra_basis(1, (1,3,1))
[[0, 0, 1], [1, 0, 0]]
sage: exterior_algebra_basis(4, (1,3,1))
[[0, 1, 1], [1, 1, 0]]
sage: exterior_algebra_basis(10, (1,5,1,1))
[]

>>> from sage.all import *
>>> from sage.algebras.commutative_dga import exterior_algebra_basis
>>> exterior_algebra_basis(Integer(1), (Integer(1),Integer(3),Integer(1)))
[[0, 0, 1], [1, 0, 0]]
>>> exterior_algebra_basis(Integer(4), (Integer(1),Integer(3),Integer(1)))
[[0, 1, 1], [1, 1, 0]]
>>> exterior_algebra_basis(Integer(10), (Integer(1),Integer(5),Integer(1),Integer(1)))
[]

sage.algebras.commutative_dga.sorting_keys(element)[source]#

Auxiliary function to sort the elements of a basis of a Cohomology group.

It is needed to ensure that elements of a cohomology group are represented in a consistent way.

INPUT:

• element – A CohomologyClass

OUTPUT:

Its coordinates in the corresponding cohomology_raw quotient vector space

EXAMPLES:

sage: from sage.algebras.commutative_dga import sorting_keys
sage: B = A.cdg_algebra({e5:e1*e2+e3*e4})
sage: B.inject_variables()
Defining e1, e2, e3, e4, e5
sage: C = B.cohomology(3)
sage: [sorting_keys(el) for el in C.basis().keys()]
[[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 0, 1]]

>>> from sage.all import *
>>> from sage.algebras.commutative_dga import sorting_keys
>>> A = GradedCommutativeAlgebra(QQ, names=('e1', 'e2', 'e3', 'e4', 'e5',)); (e1, e2, e3, e4, e5,) = A._first_ngens(5)
>>> B = A.cdg_algebra({e5:e1*e2+e3*e4})
>>> B.inject_variables()
Defining e1, e2, e3, e4, e5
>>> C = B.cohomology(Integer(3))
>>> [sorting_keys(el) for el in C.basis().keys()]
[[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 0, 1]]

sage.algebras.commutative_dga.total_degree(deg)[source]#

Total degree of deg.

INPUT:

• deg – an element of a free abelian group.

In fact, deg could be an integer, a Python int, a list, a tuple, a vector, etc. This function returns the sum of the components of deg.

EXAMPLES:

sage: from sage.algebras.commutative_dga import total_degree
sage: total_degree(12)
12
sage: total_degree(range(5))
10
sage: total_degree(vector(range(5)))
10
sage: x = G.gen(0); y = G.gen(1)
sage: 3*x+4*y
(3, 4)
sage: total_degree(3*x+4*y)
7

>>> from sage.all import *
>>> from sage.algebras.commutative_dga import total_degree
>>> total_degree(Integer(12))
12
>>> total_degree(range(Integer(5)))
10
>>> total_degree(vector(range(Integer(5))))
10