word_to_class_index¶
-
class_index_type libsemigroups::CongruenceByPairsHelper::word_to_class_index(word_type const &w)¶
If the congruence, that an object of this type represents, is defined over a semigroup with generators \(A\), then this function defines a surjective function from the set of all words over \(A\) to either \(\{0, 1, \ldots, n - 1\}\), where \(n\) is the number of classes, or to the non-negative integers \(\{0, 1, \ldots\}\) if
this
has infinitely many classes.- Complexity
See warning.
Note
CongruenceInterface::word_to_class_index and CongruenceInterface::class_index_to_word are mutually inverse functions.
Warning
The function for finding the structure of a congruence may be non-deterministic, or undecidable, and this function may never return a result.
- Parameters
w – the word whose class index we want to find. The parameter
w
must be a libsemigroups::word_type consisting of indices of the generators of the semigroup over whichthis
is defined.- Throws
LibsemigroupsException – if
w
contains a letter that is out of bounds, or the object has not been fully initialised.std::bad_alloc – if the (possibly infinite) computation uses all the available memory.
- Returns
The index of the congruence class corresponding to
word
.