Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 1e5b979

Browse files
committed
31178: fix inverse image for quotient rings
1 parent 9d686f2 commit 1e5b979

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/sage/rings/morphism.pyx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,11 +1053,30 @@ cdef class RingHomomorphism(RingMap):
10531053
sage: f = R.hom([y, x], R)
10541054
sage: f.inverse_image(x), f.inverse_image(y) # indirect doctest
10551055
(0, 0)
1056+
1057+
Check cases involving quotient rings in which a generator is constant
1058+
(:trac:`31178`)::
1059+
1060+
sage: R.<x,y> = QQ[]
1061+
sage: B.<c,d> = R.quotient(R.ideal(x))
1062+
sage: g = R.hom([d^2, d^3], B)
1063+
sage: g.inverse_image(d)
1064+
Traceback (most recent call last):
1065+
...
1066+
ValueError: element d does not have preimage
1067+
sage: g.inverse_image(d^2)
1068+
x
1069+
sage: g.inverse_image(d^3)
1070+
y
1071+
sage: A.<a,b> = R.quotient(R.ideal(y^2 - x^3))
1072+
sage: h = A.hom([d^2, d^3], B)
1073+
sage: h.inverse_image(d^2)
1074+
a
10561075
"""
10571076
graph, from_B, to_A = self._graph_ideal()
1058-
gens_B = graph.ring().gens()[:self.codomain().ngens()]
1077+
gens_A = graph.ring().gens()[-self.domain().ngens():]
10591078
a = graph.reduce(from_B(b))
1060-
if not (a.lm() < min(gens_B)) and not a.is_zero():
1079+
if not all(x in gens_A for x in a.lm().variables()):
10611080
raise ValueError(f"element {b} does not have preimage")
10621081
return to_A(a)
10631082

0 commit comments

Comments
 (0)