Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix corners cases of free resolutions #37132

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 54 additions & 12 deletions src/sage/homology/free_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

.. MATH::

R^{n_1} \xleftarrow{d_1} R^{n_1} \xleftarrow{d_2}
R^{n_0} \xleftarrow{d_1} R^{n_1} \xleftarrow{d_2}
\cdots \xleftarrow{d_k} R^{n_k} \xleftarrow{d_{k+1}} 0

terminating with a zero module at the end that is exact (all homology groups
Expand Down Expand Up @@ -242,9 +242,20 @@
'S^2'
sage: r # indirect doctest
S^1 <-- S^3 <-- S^2 <-- 0

TESTS::

sage: S.<x,y,z> = PolynomialRing(QQ)
sage: I = S.ideal(0)
sage: C = I.free_resolution()
sage: C
S^1 <-- 0
"""
if i == 0:
r = self._maps[0].nrows()
if self._length > 0:
r = self._maps[0].nrows()
else:
r = self._initial_differential.domain().dimension()
s = f'{self._name}^{r}'
return s
elif i > self._length:
Expand Down Expand Up @@ -422,6 +433,8 @@
raise IndexError('invalid index')
elif i > self._length:
F = FreeModule(self._base_ring, 0)
elif i == 0:
F = self.differential(0).domain()
elif i == self._length:
F = FreeModule(self._base_ring, self._maps[i - 1].ncols())
else:
Expand All @@ -444,11 +457,12 @@
sage: r
S(0) <-- S(-2)⊕S(-2)⊕S(-2) <-- S(-3)⊕S(-3) <-- 0
sage: r.differential(3)
Free module morphism defined by the matrix []
Domain: Ambient free module of rank 0 over the integral domain
Multivariate Polynomial Ring in x, y, z, w over Rational Field
Codomain: Ambient free module of rank 2 over the integral domain
Multivariate Polynomial Ring in x, y, z, w over Rational Field
Free module morphism defined as left-multiplication by the matrix
[]
Domain: Ambient free module of rank 0 over the integral domain
Multivariate Polynomial Ring in x, y, z, w over Rational Field
Codomain: Ambient free module of rank 2 over the integral domain
Multivariate Polynomial Ring in x, y, z, w over Rational Field
sage: r.differential(2)
Free module morphism defined as left-multiplication by the matrix
[-y x]
Expand Down Expand Up @@ -476,6 +490,31 @@
[-z^2 + y*w]
[ y*z - x*w]
[-y^2 + x*z]

TESTS::

sage: P2.<x,y,z> = ProjectiveSpace(QQ, 2)
sage: S = P2.coordinate_ring()
sage: I = S.ideal(0)
sage: C = I.graded_free_resolution(); C
S(0) <-- 0
sage: C[1]
Ambient free module of rank 0 over the integral domain
Multivariate Polynomial Ring in x, y, z over Rational Field
sage: C[0]
Ambient free module of rank 1 over the integral domain
Multivariate Polynomial Ring in x, y, z over Rational Field
sage: C.differential(1)
Free module morphism defined as left-multiplication by the matrix
[]
Domain: Ambient free module of rank 0 over the integral domain
Multivariate Polynomial Ring in x, y, z over Rational Field
Codomain: Ambient free module of rank 1 over the integral domain
Multivariate Polynomial Ring in x, y, z over Rational Field
sage: C.differential(1).matrix()
[]
sage: C.differential(1).matrix().dimensions()
(1, 0)
"""
if i < 0:
raise IndexError('invalid index')
Expand All @@ -484,14 +523,17 @@
return self._initial_differential
except AttributeError:
raise ValueError('0th differential map undefined')
elif i == self._length + 1:
s = FreeModule(self._base_ring, 0)
t = FreeModule(self._base_ring, self._maps[i - 2].ncols())
m = s.hom(0, t)
elif i > self._length + 1:
s = FreeModule(self._base_ring, 0)
t = FreeModule(self._base_ring, 0)
m = s.hom(0, t)
m = s.hom(0, t, side='right')

Check warning on line 529 in src/sage/homology/free_resolution.py

View check run for this annotation

Codecov / codecov/patch

src/sage/homology/free_resolution.py#L529

Added line #L529 was not covered by tests
elif i == self._length + 1:
s = FreeModule(self._base_ring, 0)
if self._length > 0:
t = FreeModule(self._base_ring, self._maps[i - 2].ncols())
else:
t = self._initial_differential.domain()
m = s.hom(0, t, side='right')
else:
s = FreeModule(self._base_ring, self._maps[i - 1].ncols())
t = FreeModule(self._base_ring, self._maps[i - 1].nrows())
Expand Down
Loading