The Stephen class
Class for constructing a word graph of left factors a word in a finitely presented semigroup.
This page describes the class Stephen which implements Stephen’s
procedure for constructing the WordGraph corresponding to the left
factors of a word in a finitely presented semigroup or a finitely presented
inverse semigroup. The algorithm implemented in this class is closely related
to the Todd-Coxeter algorithm (as implemented in ToddCoxeter) and
originates in [Ste87].
See also
Important
The class Stephen has all the methods of the Runner class but, for
boring technical reasons, is not a subclass of Runner. If thing is
an instance of Stephen, then you can use thing as if it were an instance
of Runner but isinstance(thing, Runner) will return False.
>>> from libsemigroups_pybind11 import (Stephen, stephen, Presentation,
... presentation)
>>> p = Presentation([0, 1])
>>> presentation.add_rule(p, [0, 0, 0], [0])
>>> presentation.add_rule(p, [1, 1, 1], [1])
>>> presentation.add_rule(p, [0, 1, 0, 1], [0, 0])
>>> s = Stephen(p)
>>> s.set_word([1, 1, 0, 1]).run()
>>> stephen.accepts(s, [1, 1, 0, 0, 1, 0])
True
>>> stephen.accepts(s, [])
False
Contents
| Class for constructing a word graph of left factors a word in a finitely presented semigroup. | |
| This function gets the accept state of the word graph. | |
| 
 | This function returns a copy of a  | 
| 
 | Initialize from a presentation. | 
| Get the initial state of the word graph. | |
| Check if the initial word is set. | |
| Get the input presentation. | |
| Set the initial word. | |
| 
 | Get the initial word. | 
| Get the word graph. | 
Full API
- class Stephen
- __init__(self: Stephen, p: Presentation) None
- This function constructs - Stephenfrom a presentation.- Parameters:
- p (Presentation) – the presentation. 
 
 - accept_state(self: Stephen) int
- This function gets the accept state of the word graph. Running this function triggers the algorithm implemented in this class (if it hasn’t been triggered already), and then returns the accept state of the produced word graph. - Returns:
- the node. 
- Return type:
- Raises:
- LibsemigroupsError – if no presentation was set at the construction or with - init()or if no word was set with- set_word().
 - Warning - Termination of the Stephen algorithm is undecidable in general, and this function may never terminate. 
 - copy(self: Stephen) Stephen
- This function returns a copy of a - Stephenobject.- Returns:
- A copy. 
- Return type:
 
 - init(self: Stephen, p: Presentation | InversePresentation) Stephen
- Initialize from a presentation. - This function puts a - Stephenobject back into the same state as if it had been newly constructed from the presentation p.- Parameters:
- p (Presentation | InversePresentation) – the presentation. 
- Returns:
- self. 
- Return type:
 
 - initial_state(self: Stephen) int
- Get the initial state of the word graph. - Returns:
- the node. 
- Return type:
 
 - is_word_set(self: Stephen) bool
- Check if the initial word is set. - Returns - Trueif a word has been set with- set_word()since the last presentation change and- Falseotherwise.- Returns:
- A bool. 
- Return type:
 
 - presentation(self: Stephen) Presentation | InversePresentation
- Get the input presentation. - Returns:
- A presentation. 
- Return type:
 
 - set_word(self: Stephen, word: list[int]) Stephen
- Set the initial word. - This function sets the word whose left factors, or equivalent words, are sought. - Parameters:
- Returns:
- self. 
- Return type:
- Raises:
- LibsemigroupsError – if any of the values in word are out of range, i.e. they do not belong to the alphabet of - Stephen.presentation.
 
 - word(self: Stephen) list[int]
- Get the initial word. - Returns the word set by - set_word().- Returns:
- A word. 
- Return type:
- Raises:
- LibsemigroupsError – if no presentation was set at the construction or with - init()or if no word was set with- set_word().
 
 - word_graph(self: Stephen) WordGraph
- Get the word graph. - This function returns the word graph in its present state. The algorithm implemented in this class is not triggered by calls to this function. - Returns:
- A - WordGraph.
- Return type:
- Raises:
- LibsemigroupsError – if no presentation was set at the construction or with - init()or if no word was set with- set_word().