Common methods

This page contains documentation of the methods of ToddCoxeter that are implemented in all of the classes Congruence, Kambites, KnuthBendix, and ToddCoxeter.

ToddCoxeter.add_generating_pair(self: ToddCoxeter, u: list[int] | str, v: list[int] | str) ToddCoxeter

Add a generating pair.

This function adds a generating pair to the congruence represented by a ToddCoxeter instance.

Parameters:
  • u (list[int] | str) – the first item in the pair.

  • v (list[int] | str) – the second item in the pair.

Returns:

self.

Return type:

ToddCoxeter

Raises:
ToddCoxeter.contains(self: ToddCoxeter, u: list[int] | str, v: list[int] | str) bool

Check containment of a pair of words.

This function checks whether or not the words u and v are contained in the congruence represented by a ToddCoxeter instance.

Parameters:
Returns:

Whether or not the pair belongs to the congruence.

Return type:

bool

Raises:

LibsemigroupsError – if any of the values in u or v is out of range, i.e. they do not belong to presentation().alphabet() and Presentation.throw_if_letter_not_in_alphabet raises.

ToddCoxeter.currently_contains(self: ToddCoxeter, u: list[int] | str, v: list[int] | str) tril

Check whether a pair of words is already known to belong to the congruence.

This function checks whether or not the words u and v are already known to be contained in the congruence represented by a ToddCoxeter instance. This function performs no enumeration, so it is possible for the words to be contained in the congruence, but that this is not currently known.

Parameters:
Returns:

Return type:

tril

Raises:

LibsemigroupsError – if any of the values in u or v is out of range, i.e. they do not belong to presentation().alphabet() and Presentation.throw_if_letter_not_in_alphabet raises.

ToddCoxeter.generating_pairs(self: ToddCoxeter) list[list[int] | str]

Get the generating pairs of the congruence.

This function returns the generating pairs of the congruence as added via ToddCoxeter.add_generating_pair.

Returns:

The list of generating pairs.

Return type:

list[list[int] | str]

ToddCoxeter.kind(self: Congruence | Kambites | KnuthBendix | ToddCoxeter) congruence_kind

The kind of the congruence (1- or 2-sided).

This function returns the kind of the congruence represented by self. See congruence_kind for details.

Returns:

The kind of the congruence (1- or 2-sided).

Return type:

congruence_kind

Complexity:

Constant.

ToddCoxeter.number_of_classes(self: ToddCoxeter) int | PositiveInfinity

Compute the number of classes in the congruence. This function computes the number of classes in the congruence represented by a ToddCoxeter instance.

Returns:

The number of congruence classes of a ToddCoxeter instance if this number is finite, or POSITIVE_INFINITY in some cases if this number is not finite.

Return type:

int | PositiveInfinity

ToddCoxeter.number_of_generating_pairs(self: Congruence | Kambites | KnuthBendix | ToddCoxeter) int

Returns the number of generating pairs.

This function returns the number of generating pairs of the congruence.

Returns:

The number of generating pairs.

Return type:

int

Complexity:

Constant.

ToddCoxeter.presentation(self: ToddCoxeter) Presentation

Get the presentation used to define a ToddCoxeter instance (if any). If a ToddCoxeter instance is constructed or initialised using a presentation, then this presentation is returned by this function.

If the ToddCoxeter instance was constructed or initialised from a WordGraph, then this presentation will be empty.

Returns:

The presentation used to construct or initialise a ToddCoxeter instance.

Return type:

Presentation

ToddCoxeter.reduce(self: ToddCoxeter, w: list[int] | str) list[int] | str

Reduce a word.

This function triggers a full enumeration of an ToddCoxeter object and then reduces the word w. As such the returned word is a normal form for the input word.

Parameters:

w (list[int] | str) – the input word.

Returns:

A normal form for the input word.

Return type:

list[int] | str

Raises:

LibsemigroupsError – if any of the values in w is out of range, i.e. they do not belong to presentation().alphabet() and Presentation.throw_if_letter_not_in_alphabet raises.

ToddCoxeter.reduce_no_run(self: ToddCoxeter, w: list[int] | str) list[int] | str

Reduce a word.

If Runner.finished returns True, then this function returns a normal form for the input word w.

If the ToddCoxeter instance is not Runner.finished, then it might be that equivalent input words produce different output words. This function triggers no congruence enumeration.

Parameters:

w (list[int] | str) – the input word.

Returns:

A word equivalent to the input word.

Return type:

list[int] | str

Raises:

LibsemigroupsError – if any of the values in w is out of range, i.e. they do not belong to presentation().alphabet() and Presentation.throw_if_letter_not_in_alphabet raises.