Exemplo n.º 1
0
def test_freely_reduced():
    generators = frozenset(Word(c) for c in 'abcde')
    e = identity = Word('e')
    F = FreeGroup(generators, identity)
    a = Word('a')
    b = Word('b')
    a_inv = F.inverse(a)
    b_inv = F.inverse(b)
    assert freely_reduced(F, a + a_inv) == identity
    assert freely_reduced(F, a + b + b_inv + a_inv) == identity
    assert freely_reduced(F, a + a + b + b_inv + a_inv) == a
    assert freely_reduced(F, a + e + b) == a + b
Exemplo n.º 2
0
def test_power():
    a, b, c, e = (Word(c) for c in 'abce')
    F = FreeGroup({a, b, c, e}, e)
    for x in (a, b, c, e):
        assert F.power(x, 0) == e
        assert F.power(x, 1) == x
        assert freely_reduced(F, x + F.power(x, -1)) == e
        assert F.power(x, 2) == x + x
        assert F.power(x, 3) == x + x + x
Exemplo n.º 3
0
def test_inverse():
    a, b, c, e = (Word(c) for c in 'abce')
    F = FreeGroup({a, b, c, e}, e)
    abc = a + b + c
    abc_inv = F.inverse(abc)
    assert freely_reduced(F, abc + abc_inv) == e