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 in- Stephen.word_graphwith source- 0and target- Stephen.accept_state.- For a - Stepheninstance constructed from a- Presentation, a word w is accepted if and only if w is equivalent to- Stephen.wordin the semigroup defined by- Stephen.presentation.- For a - Stepheninstance constructed from a- InversePresentation, a word w is accepted if and only if \(uu^{-1}w\) is equivalent to \(u\) in the semigroup defined by- Stephen.presentation, where \(u\) is the value of- Stephen.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 with- Stephen.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 the- Stephenobject 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 of- Stephen.wordin the semigroup defined by- Stephen.presentation. A word is a left factor of- Stephen.wordif it labels a path in- Stephen.word_graphwith source- 0.- 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 with- Stephen.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 of- Stephen.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 of- Stephen.word.
- Return type:
- Raises:
- LibsemigroupsError – if no presentation was set at the construction of s or with - Stephen.initor if no word was set with- Stephen.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 in- Stephen.word_graph(if the inherited- Runner.runmethod of s has been called) with source- 0and 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 - intor- POSITIVE_INFINITY.
- Return type:
- Raises:
- LibsemigroupsError – if no presentation was set at the construction of s or with - Stephen.initor if no word was set with- Stephen.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 source- 0, target- Stephen.accept_state, and length in the range min to max.- For a - Stepheninstance constructed from a- Presentationthis is the same as the number of words that are equivalent to- Stephen.wordwith length between min and max.- For a - Stepheninstance constructed from a- InversePresentation, this is the same as the number of words w such that \(uu^{-1}w\) is equivalent to \(u\) in the semigroup defined by- Stephen.presentation, where \(u\) is the value of- Stephen.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 with- Stephen.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 to- Stephen.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 with- Stephen.set_word.
 - Warning - Termination of the Stephen algorithm is undecidable in general, and this function may never terminate.