def test_is_rewritable_or_comparable(): # from katsura4 with grlex R, x, y, z, t = ring("x,y,z,t", QQ, grlex) p = lbp(sig((0, 0, 2, 1), 2), R.zero, 2) B = [ lbp( sig((0, 0, 0, 1), 2), QQ(2, 45) * y**2 + QQ(1, 5) * y * z + QQ(5, 63) * y * t + z**2 * t + QQ(4, 45) * z**2 + QQ(76, 35) * z * t**2 - QQ(32, 105) * z * t + QQ(13, 7) * t**3 - QQ(13, 21) * t**2, 6) ] # rewritable: assert is_rewritable_or_comparable(Sign(p), Num(p), B) is True p = lbp(sig((0, 1, 1, 0), 2), R.zero, 7) B = [ lbp( sig((0, 0, 0, 0), 3), QQ(10, 3) * y * z + QQ(4, 3) * y * t - QQ(1, 3) * y + 4 * z**2 + QQ(22, 3) * z * t - QQ(4, 3) * z + 4 * t**2 - QQ(4, 3) * t, 3) ] # comparable: assert is_rewritable_or_comparable(Sign(p), Num(p), B) is True
def test_is_rewritable_or_comparable(): # from katsura4 with grlex p = lbp(sig((0, 0, 2, 1), 2), [], 2) B = [ lbp(sig((0, 0, 0, 1), 2), [((0, 0, 2, 1), QQ(1, 1)), ((0, 0, 1, 2), QQ(76, 35)), ((0, 0, 0, 3), QQ(13, 7)), ((0, 2, 0, 0), QQ(2, 45)), ((0, 1, 1, 0), QQ(1, 5)), ((0, 1, 0, 1), QQ(5, 63)), ((0, 0, 2, 0), QQ(4, 45)), ((0, 0, 1, 1), QQ(-32, 105)), ((0, 0, 0, 2), QQ(-13, 21))], 6) ] # rewritable: assert is_rewritable_or_comparable(Sign(p), Num(p), B, 3, QQ) is True p = lbp(sig((0, 1, 1, 0), 2), [], 7) B = [ lbp(sig((0, 0, 0, 0), 3), [((0, 1, 1, 0), QQ(10, 3)), ((0, 1, 0, 1), QQ(4, 3)), ((0, 0, 2, 0), QQ(4, 1)), ((0, 0, 1, 1), QQ(22, 3)), ((0, 0, 0, 2), QQ(4, 1)), ((0, 1, 0, 0), QQ(-1, 3)), ((0, 0, 1, 0), QQ(-4, 3)), ((0, 0, 0, 1), QQ(-4, 3))], 3) ] # comparable: assert is_rewritable_or_comparable(Sign(p), Num(p), B, 3, QQ) is True
def test_f5_reduce(): # katsura3 with lex R, x, y, z = ring("x,y,z", QQ, lex) F = [ (((0, 0, 0), 1), x + 2 * y + 2 * z - 1, 1), (((0, 0, 0), 2), 6 * y ** 2 + 8 * y * z - 2 * y + 6 * z ** 2 - 2 * z, 2), ( ((0, 0, 0), 3), QQ(10, 3) * y * z - QQ(1, 3) * y + 4 * z ** 2 - QQ(4, 3) * z, 3, ), (((0, 0, 1), 2), y + 30 * z ** 3 - QQ(79, 7) * z ** 2 + QQ(3, 7) * z, 4), ( ((0, 0, 2), 2), z ** 4 - QQ(10, 21) * z ** 3 + QQ(1, 84) * z ** 2 + QQ(1, 84) * z, 5, ), ] cp = critical_pair(F[0], F[1], R) s = s_poly(cp) assert f5_reduce(s, F) == (((0, 2, 0), 1), R.zero, 1) s = lbp(sig(Sign(s)[0], 100), Polyn(s), Num(s)) assert f5_reduce(s, F) == s
def test_f5_reduce(): # katsura3 with lex F = [(((0, 0, 0), 1), [((1, 0, 0), QQ(1,1)), ((0, 1, 0), QQ(2,1)), ((0, 0, 1), QQ(2,1)), ((0, 0, 0), QQ(-1,1))], 1), (((0, 0, 0), 2), [((0, 2, 0), QQ(6,1)), ((0, 1, 1), QQ(8,1)), ((0, 1, 0), QQ(-2,1)), ((0, 0, 2), QQ(6,1)), ((0, 0, 1), QQ(-2,1))], 2), (((0, 0, 0), 3), [((0, 1, 1), QQ(10,3)), ((0, 1, 0), QQ(-1,3)), ((0, 0, 2), QQ(4,1)), ((0, 0, 1), QQ(-4,3))], 3), (((0, 0, 1), 2), [((0, 1, 0), QQ(1,1)), ((0, 0, 3), QQ(30,1)), ((0, 0, 2), QQ(-79,7)), ((0, 0, 1), QQ(3,7))], 4), (((0, 0, 2), 2), [((0, 0, 4), QQ(1,1)), ((0, 0, 3), QQ(-10,21)), ((0, 0, 2), QQ(1,84)), ((0, 0, 1), QQ(1,84))], 5)] cp = critical_pair(F[0], F[1], 2, lex, QQ) s = s_poly(cp, 2, lex, QQ) assert f5_reduce(s, F, 2, lex, QQ) == (((0, 2, 0), 1), [], 1) s = lbp(sig(Sign(s)[0], 100), Polyn(s), Num(s)) assert f5_reduce(s, F, 2, lex, QQ) == s