示例#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
示例#2
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
示例#3
0
def test_missing_identity():
    generators = frozenset(Word(c) for c in 'abcd')
    e = identity = Word('e')
    F = FreeGroup(generators, identity)
    assert e == F.identity
    assert F.inverse(e) == e
示例#4
0
def test_identity():
    generators = frozenset(Word(c) for c in 'abe')
    identity = Word('e')
    F = FreeGroup(generators, identity)
    assert identity == F.inverse(identity)