Converting to a Congruence
This page contains documentation relating to converting
libsemigroups_pybind11 objects into Congruence 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, rtype).
In what follows, we explain how different values of args and rtype may be
used to construct Congruence objects. The following options are possible:
Converting a FroidurePin to a Congruence
To construct a Congruence from a FroidurePin, specify all of the
following values for args:
knd (
congruence_kind) – the kind of the congruence being constructed;fpb (
FroidurePin) – theFroidurePininstance to be converted; andwg (
WordGraph) – the left or right Cayley graph of fpb.
Additionally, specify one of the following tuples for rtype:
(Congruence, str)for constructing aCongruenceon words of typestr; or
(Congruence, list[int])for constructing aCongruenceon words of typelist[int].
This function converts the FroidurePin object fpb into a
Congruence object using the WordGraph wg (which should be either
the FroidurePin.left_cayley_graph or the
FroidurePin.right_cayley_graph of fpb).
This returned Congruence object represents the trivial congruence over
the semigroup defined by fpb.
This will throw a LibsemigroupsError if wg is not the
FroidurePin.left_cayley_graph or the
FroidurePin.right_cayley_graph of fpb.
>>> from libsemigroups_pybind11 import (
... Bipartition,
... congruence_kind,
... Congruence,
... FroidurePin,
... to,
... )
>>> 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)
>>> cong = to(
... congruence_kind.twosided, # knd
... S, # fpb
... S.right_cayley_graph(), # wg
... rtype=(Congruence, str),
... )
>>> cong.run()
>>> S.size() == cong.number_of_classes()
True
Converting a WordGraph to a Congruence
To construct a Congruence from a WordGraph, specify all of the
following values for args:
knd (
congruence_kind) – the kind of the congruence being constructed;wg (
WordGraph) – the word graph.
Additionally, specify one of the following tuples for rtype:
(Congruence, str)for constructing aCongruenceon words of typestr; or
(Congruence, list[int])for constructing aCongruenceon words of typelist[int].
This function converts the WordGraph object wg into a
Congruence object. This returned Congruence object represents the
trivial congruence over the word graph wg.
>>> from libsemigroups_pybind11 import (
... congruence_kind,
... Congruence,
... WordGraph,
... to,
... )
>>> wg = WordGraph(7, [[1, 2], [1, 3], [4, 2], [5, 3], [4, 6], [5, 3], [4, 6]])
>>> cong = to(congruence_kind.twosided, wg, rtype=(Congruence, list[int]))
>>> cong.add_generating_pair([0], [1])
<1-sided Congruence over <semigroup presentation with 2 letters, 0 rules, and length 0> with 1 gen. pair, 1 runners>
>>> cong.number_of_classes()
1
>>> cong = to(congruence_kind.twosided, wg, rtype=(Congruence, str))
>>> cong.add_generating_pair("a", "b")
<1-sided Congruence over <semigroup presentation with 2 letters, 0 rules, and length 0> with 1 gen. pair, 1 runners>
>>> cong.number_of_classes()
1