Converting to a KnuthBendix

This page contains documentation relating to converting libsemigroups_pybind11 objects into KnuthBendix instances using the to function.

See also

The to function for an overview of possible conversions between libsemigroups_pybind11 types.

Various uses

Recall that the signature for the to function is to(*args, Return). In what follows, we explain how different values of args and Return may be used to construct KnuthBendix objects. The following options are possible:

Converting a ToddCoxeter to a KnuthBendix (default rewriter)

To construct a KnuthBendix from a ToddCoxeter using the default rewriter, specify all of the following values for args:

Additionally, specify the following for Return:

  • (KnuthBendix,) for constructing a KnuthBendix with the default rewriter.

This function converts a ToddCoxeter object tc to a KnuthBendix object using ToddCoxeter.presentation. This is equivalent to specifying (KnuthBendix, 'RewriteTrie') as described below.

This returned KnuthBendix object represents the trivial congruence over the semigroup defined by tc.

>>> from libsemigroups_pybind11 import (
...     congruence_kind,
...     to,
...     KnuthBendix,
...     Presentation,
...     presentation,
...     ToddCoxeter,
... )

>>> p = Presentation('ab')
>>> presentation.add_rule(p, 'ab', 'ba')
>>> presentation.add_rule(p, 'aa', 'a')
>>> presentation.add_rule(p, 'bb', 'b')

>>> tc = ToddCoxeter(congruence_kind.twosided, p)

>>> kb = to(
...     congruence_kind.twosided,   # knd
...     tc,                         # tc
...     rtype=(KnuthBendix,)
... )
>>> kb.run()

>>> kb.number_of_classes() == tc.number_of_classes()
True

Converting a ToddCoxeter to a KnuthBendix

To construct a KnuthBendix from a ToddCoxeter, specify all of the following values for args:

Additionally, specify one of the following for Return:

  • (KnuthBendix, 'RewriteTrie') for constructing a KnuthBendix with the the RewriteTrie' rewriter.

  • (KnuthBendix, 'RewriteFromLeft') for constructing a KnuthBendix with the the RewriteFromLeft' rewriter.

This function converts a ToddCoxeter object tc to a KnuthBendix object with the rewriter as specified above, using ToddCoxeter.presentation.

This returned KnuthBendix object represents the trivial congruence over the semigroup defined by tc.

>>> from libsemigroups_pybind11 import (
...     congruence_kind,
...     to,
...     KnuthBendix,
...     Presentation,
...     presentation,
...     ToddCoxeter,
... )

>>> p = Presentation('ab')
>>> presentation.add_rule(p, 'ab', 'ba')
>>> presentation.add_rule(p, 'aa', 'a')
>>> presentation.add_rule(p, 'bb', 'b')

>>> tc = ToddCoxeter(congruence_kind.twosided, p)

>>> kb = to(
...     congruence_kind.twosided,               # knd
...     tc,                                     # tc
...     rtype=(KnuthBendix, 'RewriteFromLeft')
... )
>>> kb.run()

>>> kb.number_of_classes() == tc.number_of_classes()
True

Converting a FroidurePin to a KnuthBendix

To construct a KnuthBendix from a FroidurePin, specify all of the following values for args:

Additionally, specify one of the following for Return:

  • (KnuthBendix, str, 'RewriteTrie') for constructing a KnuthBendix on words with type str using the RewriteTrie' rewriter.

  • (KnuthBendix, list[int], 'RewriteTrie') for constructing a KnuthBendix on words with type list[int] using the RewriteTrie' rewriter.

  • (KnuthBendix, str, 'RewriteFromLeft') for constructing a KnuthBendix on words with type str using the RewriteFromLeft' rewriter.

  • (KnuthBendix, list[int], 'RewriteFromLeft') for constructing a KnuthBendix on words with type list[int] using the RewriteFromLeft' rewriter.

This function converts a FroidurePin object fpb to a KnuthBendix object with the word type and rewriter as specified above. This is done using the presentation obtained from to(fpb, rtype=(Presentation, Word) where Word is either str or list[int].

This returned KnuthBendix object represents the trivial congruence over the semigroup defined by fpb.

>>> from libsemigroups_pybind11 import (
...     Bipartition,
...     congruence_kind,
...     FroidurePin,
...     to,
...     KnuthBendix,
...     Presentation,
...     presentation,
... )

>>> b1 = Bipartition([[1, -1], [2, -2], [3, -3], [4, -4]])
>>> b2 = Bipartition([[1, -2], [2, -3], [3, -4], [4, -1]])
>>> b3 = Bipartition([[1, -2], [2, -1], [3, -3], [4, -4]])
>>> b4 = Bipartition([[1, 2], [3, -3], [4, -4], [-1, -2]])
>>> S = FroidurePin(b1, b2, b3, b4)

>>> kb = to(
...     congruence_kind.twosided,                           # knd
...     S,                                                  # tc
...     rtype=(KnuthBendix, list[int], 'RewriteFromLeft')
... )
>>> kb.run()

>>> kb.number_of_classes() == S.size()
True