Stephen helpers
This page contains the documentation for various helper functions for
manipulating Stephen objects.
Contents
|
Check if a word is accepted by a |
|
Return a |
Check if a word is a left factor of |
|
|
Returns a |
Returns the number of left factors with length in a given range. |
|
Returns the number of words accepted with length in a given range. |
|
Returns a |
Full API
This page contains the documentation for various helper functions for
manipulating Stephen objects. All such functions
are contained in the submodule stephen.
- stephen.accepts(s: Stephen, w: list[int]) bool
Check if a word is accepted by a
Stepheninstance.This function triggers the algorithm implemented in this class (if it hasn’t been triggered already), and then returns
Trueif the input word w labels a path inStephen.word_graphwith source0and targetStephen.accept_state.For a
Stepheninstance constructed from aPresentation, a word w is accepted if and only if w is equivalent toStephen.wordin the semigroup defined byStephen.presentation.For a
Stepheninstance constructed from aInversePresentation, a word w is accepted if and only if \(uu^{-1}w\) is equivalent to \(u\) in the semigroup defined byStephen.presentation, where \(u\) is the value ofStephen.word.- Parameters:
- Returns:
A
bool.- Return type:
- Raises:
LibsemigroupsError – if no presentation was set at the construction of s or with
Stephen.initor if no word was set withStephen.set_word.
Warning
Termination of the Stephen algorithm is undecidable in general, and this function may never terminate.
- stephen.dot(s: Stephen) Dot
Return a
Dotobject representing the underlying word graph of theStephenobject s.
- stephen.is_left_factor(s: Stephen, w: list[int]) bool
Check if a word is a left factor of
Stephen.word.This function triggers the algorithm implemented in this class (if it hasn’t been triggered already), and then returns
Trueif the input word w is a left factor ofStephen.wordin the semigroup defined byStephen.presentation. A word is a left factor ofStephen.wordif it labels a path inStephen.word_graphwith source0.- Parameters:
- Returns:
A
bool.- Return type:
- Raises:
LibsemigroupsError – if no presentation was set at the construction of s or with
Stephen.initor if no word was set withStephen.set_word.
Warning
Termination of the Stephen algorithm is undecidable in general, and this function may never terminate.
- stephen.left_factors(s: Stephen) Paths
Returns a
Pathsobject containing all the words (in short-lex order) that are left factors ofStephen.word.This function triggers the algorithm implemented in this class (if it hasn’t been triggered already).
- Parameters:
s (Stephen) – the Stephen instance
- Returns:
A
Pathsobject containing all the words (in short-lex order) that are left factors ofStephen.word.- Return type:
- Raises:
LibsemigroupsError – if no presentation was set at the construction of s or with
Stephen.initor if no word was set withStephen.set_word.
Warning
Termination of the Stephen algorithm is undecidable in general, and this function may never terminate.
- stephen.number_of_left_factors(s: Stephen, min: int = 0, max: int | PositiveInfinity = POSITIVE_INFINITY) int | PositiveInfinity
Returns the number of left factors with length in a given range.
This function returns the number of left factors of the
Stephen.wordin the instance s with length between min and max. This is the same as the number of paths inStephen.word_graph(if the inheritedRunner.runmethod of s has been called) with source0and length in the range min to max.- Parameters:
s (Stephen) – the Stephen instance.
min (int) – the minimum length of a word (default: 0).
max (int | PositiveInfinity) – one more than the maximum length of a word (default:
POSITIVE_INFINITY).
- Returns:
An
intorPOSITIVE_INFINITY.- Return type:
- Raises:
LibsemigroupsError – if no presentation was set at the construction of s or with
Stephen.initor if no word was set withStephen.set_word.
Warning
Termination of the Stephen algorithm is undecidable in general, and this function may never terminate.
- stephen.number_of_words_accepted(s: Stephen, min: int = 0, max: int | PositiveInfinity = POSITIVE_INFINITY) int | PositiveInfinity
Returns the number of words accepted with length in a given range.
This function triggers the algorithm implemented in this class (if it hasn’t been triggered already) and then returns the the number of paths in
Stephen.word_graphwith source0, targetStephen.accept_state, and length in the range min to max.For a
Stepheninstance constructed from aPresentationthis is the same as the number of words that are equivalent toStephen.wordwith length between min and max.For a
Stepheninstance constructed from aInversePresentation, this is the same as the number of words w such that \(uu^{-1}w\) is equivalent to \(u\) in the semigroup defined byStephen.presentation, where \(u\) is the value ofStephen.word.- Parameters:
s (Stephen) – the Stephen instance.
min (int) – the minimum length of a word (default:
0).max (int | PositiveInfinity) – one more than the maximum length of a word (default:
POSITIVE_INFINITY).
- Returns:
The number of words accepted.
- Return type:
- Raises:
LibsemigroupsError – if no presentation was set at the construction of s or with
Stephen.initor if no word was set withStephen.set_word.
Warning
Termination of the Stephen algorithm is undecidable in general, and this function may never terminate.
- stephen.words_accepted(s: Stephen) Paths
Returns a
Pathsobject containing all words accepted by a Stephen instance in short-lex order.This function triggers the algorithm implemented in this class (if it hasn’t been triggered already).
- Parameters:
s (Stephen) – the Stephen instance
- Returns:
A
Pathsobject containing all words equivalent toStephen.wordin short-lex order.- Return type:
- Raises:
LibsemigroupsError – if no presentation was set at the construction of s or with
Stephen.initor if no word was set withStephen.set_word.
Warning
Termination of the Stephen algorithm is undecidable in general, and this function may never terminate.