The MinimalRepOrc class
For computing the minimal degree of a transformation representation arising from a right congruence of a finite semigroup or monoid.
This class is a helper for Sims1
, calling the word_graph
member
function attempts to find a right congruence, represented as an
WordGraph
, with the minimum possible number of nodes such that the
action of the semigroup or monoid defined by the presentation consisting of its
presentation()
on the nodes of the WordGraph
corresponds to a semigroup of size target_size()
.
If no such :WordGraph
can be found, then an empty WordGraph
is
returned (with 0
nodes and 0
edges).
Contents
For computing the minimal degree of a transformation representation arising from a right congruence of a finite semigroup or monoid. |
|
Add a pair that must be excluded from every congruence. |
|
Add a pair that should be included in every congruence. |
|
Add a pruner to the search tree. |
|
Clear the set of excluded words. |
|
Clear the set of included words. |
|
Clear the set of long rules. |
|
Clear the set of pruners. |
|
Returns the set of pairs that must be excluded from every congruence. |
|
Set the beginning of the long rules (position). |
|
Overloaded function. |
|
Returns the set of pairs that must be excluded from every congruence. |
|
Overloaded function. |
|
Set the length of a long rule. |
|
Get the long rules. |
|
Returns the number of rules marked as long rules. |
|
Overloaded function. |
|
Overloaded function. |
|
Get all active pruners of the search tree. |
|
Get the current stats object. |
|
Overloaded function. |
|
Get the word graph. |
Full API
- class MinimalRepOrc
- __init__(self: MinimalRepOrc, word: type) None
This function returns an uninitialized
MinimalRepOrc
object that uses words of type specified by word.- Keyword Arguments:
word (type) – the type of words to use, must be
list[int]
.
- add_excluded_pair(self: MinimalRepOrc, lhs: list[int], rhs: list[int]) MinimalRepOrc
Add a pair that must be excluded from every congruence.
- Parameters:
- Returns:
The first argument self.
- Return type:
- Raises:
LibsemigroupsError – if
Presentation.throw_if_letter_not_in_alphabet
throws on lhs or rhs.
- add_included_pair(self: MinimalRepOrc, lhs: list[int], rhs: list[int]) MinimalRepOrc
Add a pair that should be included in every congruence.
- Parameters:
- Returns:
The first argument self.
- Return type:
- Raises:
LibsemigroupsError – if
Presentation.throw_if_letter_not_in_alphabet
throws on lhs or rhs.
- add_pruner(self: MinimalRepOrc, pruner: collections.abc.Callable[[WordGraph], bool]) MinimalRepOrc
Add a pruner to the search tree.
- Parameters:
pruner (collections.abc.Callable[[WordGraph], bool]) – a pruner function.
- Returns:
The first argument self.
- Return type:
Warning
When running the Sims low-index backtrack with multiple threads, each added pruner must be guaranteed thread safe. Failing to do so could cause bad things to happen.
- clear_excluded_pairs(self: MinimalRepOrc) MinimalRepOrc
Clear the set of excluded words.
- Returns:
The first argument self.
- Return type:
- clear_included_pairs(self: MinimalRepOrc) MinimalRepOrc
Clear the set of included words.
- Returns:
The first argument self.
- Return type:
- clear_long_rules(self: MinimalRepOrc) MinimalRepOrc
Clear the set of long rules.
- Returns:
The first argument self.
- Return type:
- clear_pruners(self: MinimalRepOrc) MinimalRepOrc
Clear the set of pruners.
- Returns:
The first argument self.
- Return type:
- excluded_pairs(self: MinimalRepOrc) list[list[int]]
Returns the set of pairs that must be excluded from every congruence.
This function returns the list of excluded pairs. The congruences computed by a
Sims1
orSims2
instance will never contain the relations of this presentation. In other words, the congruences computed by this instance are only taken among those that do not contain any of the pairs of elements of the underlying semigroup (defined by the presentation returned bypresentation()
andlong_rules()
) represented by the relations of the presentation returned byexcluded_pairs()
.
- first_long_rule_position(self: MinimalRepOrc, pos: int) MinimalRepOrc
Set the beginning of the long rules (position).
This function sets the beginning of the long rules using a position in
self.presentation().rules
. The “long rules” are the rules used after a complete deterministic word graph has been found in the search. If such a word graph is compatible with the long rules specified by this function, then this word graph is accepted, and if not it is rejected.The purpose of this is to improve the backtrack search by reducing the time spent processing “long” rules in each node of the search tree, and to only check them at the leaves.
- Parameters:
pos (int) – position of the the left hand side of the first long rule.
- Returns:
The first argument self.
- Return type:
- Raises:
LibsemigroupsError – if pos is not a valid position in
self.presentation().rules
.LibsemigroupsError – if the rule at position pos is not the left hand side of a rule (i.e. if pos is odd).
- idle_thread_restarts(self: MinimalRepOrc, val: int) MinimalRepOrc
Overloaded function.
- idle_thread_restarts(self: MinimalRepOrc) int
Get the idle thread restart attempt count.
This function returns the number of times an idle thread will attempt to restart before yielding during execution.
- Returns:
The number of idle thread restarts.
- Return type:
- idle_thread_restarts(self: MinimalRepOrc, val: int) MinimalRepOrc
Set the idle thread restart attempt count.
This function sets the idle thread restart attempt count. The default value is
64
.- Parameters:
val (int) – the maximum number of times an idle thread will attempt to restart before yielding.
- Returns:
The first argument self.
- Return type:
- Raises:
LibsemigroupsError – if the argument val is 0.
- included_pairs(self: MinimalRepOrc) list[list[int]]
Returns the set of pairs that must be excluded from every congruence.
This function returns the list of included pairs. The congruences computed by a
Sims1
orSims2
instance always contain the relations of this list. In other words, the congruences computed by this instance are only taken among those that contains the pairs of elements of the underlying semigroup (defined by the presentation returned bypresentation()
andlong_rules()
) represented by the relations of the list of words returned byincluded_pairs()
.
- init(*args, **kwargs)
Overloaded function.
- init(self: MinimalRepOrc) MinimalRepOrc
Reinitialize an existing
MinimalRepOrc
object.This function puts a
MinimalRepOrc
object back into the same state as if it had been newly default constructed.- Returns:
The first argument self.
- Return type:
- init(self: MinimalRepOrc, that: MinimalRepOrc) MinimalRepOrc
Reinitialize an existing
MinimalRepOrc
object.This function re-initializes a
MinimalRepOrc
instance to be in the same state as that.- Parameters:
that (MinimalRepOrc) – The instance use for reinitialization.
- Returns:
The re-initialized object.
- Return type:
- long_rule_length(self: MinimalRepOrc, val: int) MinimalRepOrc
Set the length of a long rule.
Define the length of a “long” rule. This function modifies
presentation()
so that the rules whose length (sum of the lengths of both sides) is at least val (if any) occur at the end ofpresentation().rules
and so thatlong_rules()
returns all such rules. The relative orders of the rules withinpresentation()
may not be preserved.- Parameters:
val (int) – the long rule length.
- Returns:
The first argument self.
- Return type:
- long_rules(self: MinimalRepOrc) collections.abc.Iterator[tuple[list[int], list[int]]]
Get the long rules.
Returns an iterator of long rules.
- number_of_long_rules(self: MinimalRepOrc) int
Returns the number of rules marked as long rules.
- Returns:
The number of long rules.
- Return type:
- number_of_threads(self: MinimalRepOrc, val: int) MinimalRepOrc
Overloaded function.
- number_of_threads(self: MinimalRepOrc, val: int) MinimalRepOrc
Set the number of threads.
This function sets the number of threads to be used by
Sims1
orSims2
. The default value is1
.- Parameters:
val (int) – the maximum number of threads to use.
- Returns:
The first argument self.
- Return type:
- Raises:
LibsemigroupsError – if the argument val is 0.
- number_of_threads(self: MinimalRepOrc) int
Get the number of threads.
- Returns:
The current maximum number of threads.
- Return type:
- presentation(*args, **kwargs)
Overloaded function.
- presentation(self: MinimalRepOrc, p: Presentation) MinimalRepOrc
Set the presentation over which the congruences produced by an instance are defined.
This function sets the presentation over which the congruences produced by an instance are defined. These are the rules used at every node in the depth first search conducted by objects of this type. The parameter p is always first converted to a
Presentation
oflist[int]
and it is this converted value that is used.- Parameters:
p (Presentation) – the presentation.
- Returns:
The first argument self.
- Return type:
- Raises:
LibsemigroupsError – if
Presentation.throw_if_bad_alphabet_or_rules
throws.LibsemigroupsError – if p has 0-generators and 0-relations.
- presentation(self: MinimalRepOrc) Presentation
Get the presentation over which the congruences produced by an instance are defined.
This function returns the defining presentation of a
Sims1
orSims2
instance. The congruences computed bySims1.iterator
of the appropriate subclass are defined over the semigroup or monoid defined by this presentation.- Returns:
The presentation.
- Return type:
- pruners(self: MinimalRepOrc) list[collections.abc.Callable[[WordGraph], bool]]
Get all active pruners of the search tree.
This function returns a copy of the list of pruners. A pruner is any function that takes as input a word graph and returns a boolean. We require that if a pruner returns
False
for a word graphwg
, then it returnsFalse
for all word graphs that are descended fromwg
in the Sims word graph search tree.The pruners are used to refine the congruence search tree during the execution of the Sims algorithm. As such, the congruences computed by this instance are only taken among those whose word graphs are accepted by all pruners returned by
pruners()
.- Returns:
A list of boolean functions on word graphs, the set of all pruners.
- Return type:
- stats(self: MinimalRepOrc) SimsStats
Get the current stats object.
This function returns the current stats object. The value returned by this function is a
SimsStats
object which contains some statistics related to the currentSims1
orSims2
instance and any part of the depth first search already conducted.
- target_size(self: MinimalRepOrc, val: int) MinimalRepOrc
Overloaded function.
- target_size(self: MinimalRepOrc) int
Get the current target size.
This function returns the current value for the target size, i.e. the desired size of the transformation semigroup corresponding to the
WordGraph
returned by the functionword_graph()
.- Returns:
A value of type
int
.- Return type:
- target_size(self: MinimalRepOrc, val: int) MinimalRepOrc
Set the target size.
This function sets the target size, i.e. the desired size of the transformation semigroup corresponding to the
WordGraph
returned by the functionword_graph()
.- Parameters:
val (int) – the target size.
- Returns:
The first argument self.
- Return type:
- word_graph(self: MinimalRepOrc) WordGraph
Get the word graph.
This function attempts to find a right congruence, represented as an
WordGraph
, with the minimum possible number of nodes such that the action of the semigroup or monoid defined by the presentation consisting of itspresentation()
andlong_rules()
on the nodes of theWordGraph
corresponds to a semigroup of sizetarget_size()
. If no suchWordGraph
can be found, then an emptyWordGraph
is returned (with0
nodes and0
edges).The algorithm implemented by this function repeatedly runs:
RepOrc(self) .min_nodes(1) .max_nodes(best) .target_size(self.target_size()) .word_graph();
where
best
is initiallytarget_size()
, until the returnedWordGraph
is empty, and then the penultimateWordGraph
is returned (if any).