def test_properties(): R = QQ[x, y] F = R.free_module(2) h = homomorphism(F, F, [[x, 0], [y, 0]]) assert h.kernel() == F.submodule([-y, x]) assert h.image() == F.submodule([x, 0], [y, 0]) assert not h.is_injective() assert not h.is_surjective() assert h.restrict_codomain(h.image()).is_surjective() assert h.restrict_domain(F.submodule([1, 0])).is_injective() assert h.quotient_domain(h.kernel()).restrict_codomain(h.image()).is_isomorphism() R2 = QQ.poly_ring(x, y, order=(("lex", x), ("ilex", y))) / [x**2 + 1] F = R2.free_module(2) h = homomorphism(F, F, [[x, 0], [y, y + 1]]) assert h.is_isomorphism()
def test_properties(): R = QQ[x, y] F = R.free_module(2) h = homomorphism(F, F, [[x, 0], [y, 0]]) assert h.kernel() == F.submodule([-y, x]) assert h.image() == F.submodule([x, 0], [y, 0]) assert not h.is_injective() assert not h.is_surjective() assert h.restrict_codomain(h.image()).is_surjective() assert h.restrict_domain(F.submodule([1, 0])).is_injective() assert h.quotient_domain(h.kernel()).restrict_codomain( h.image()).is_isomorphism() R2 = QQ.poly_ring(x, y, order=(("lex", x), ("ilex", y))) / [x**2 + 1] F = R2.free_module(2) h = homomorphism(F, F, [[x, 0], [y, y + 1]]) assert h.is_isomorphism()
def test_QuotientRing(): I = QQ[x].ideal(x**2 + 1) R = QQ[x] / I assert R == QQ[x] / [x**2 + 1] assert R == QQ[x] / QQ[x].ideal(x**2 + 1) assert R != QQ[x] assert R.convert(1) / x == -x + I assert -1 + I == x**2 + I assert R.convert(1, ZZ) == 1 + I assert R.convert(R.convert(x), R) == R.convert(x) X = R.convert(x) Y = QQ[x].convert(x) assert -1 + I == X**2 + I assert -1 + I == Y**2 + I assert R.to_sympy(X) == x raises(ValueError, lambda: QQ[x] / QQ[x, y].ideal(x)) R = QQ.poly_ring(x, order="ilex") I = R.ideal(x) assert R.convert(1) + I == (R / I).convert(1)
def test_QuotientRing(): I = QQ[x].ideal(x**2 + 1) R = QQ[x]/I assert R == QQ[x]/[x**2 + 1] assert R == QQ[x]/QQ[x].ideal(x**2 + 1) assert R != QQ[x] assert R.convert(1)/x == -x + I assert -1 + I == x**2 + I assert R.convert(1, ZZ) == 1 + I assert R.convert(R.convert(x), R) == R.convert(x) X = R.convert(x) Y = QQ[x].convert(x) assert -1 + I == X**2 + I assert -1 + I == Y**2 + I assert R.to_sympy(X) == x raises(ValueError, lambda: QQ[x]/QQ[x, y].ideal(x)) R = QQ.poly_ring(x, order="ilex") I = R.ideal(x) assert R.convert(1) + I == (R/I).convert(1)