39#ifndef LIBSEMIGROUPS_SCHREIER_SIMS_HPP_
40#define LIBSEMIGROUPS_SCHREIER_SIMS_HPP_
51#include <unordered_set>
53#include "adapters.hpp"
56#include "exception.hpp"
60#include "detail/bruidhinn-traits.hpp"
61#include "detail/containers.hpp"
62#include "detail/fmt.hpp"
63#include "detail/int-range.hpp"
98 template <
size_t N,
typename Po
int,
typename Element>
178 "incompatible point types, Traits::point_type and Point "
182 "incompatible element types, Traits::element_type and Element "
184 static_assert(N <= std::numeric_limits<Point>::max(),
185 "the first template parameter N cannot be expressed as value "
186 "of type equal to the second template parameter Point");
188 using internal_element_type =
189 typename detail::BruidhinnTraits<Element>::internal_value_type;
190 using internal_reference =
191 typename detail::BruidhinnTraits<Element>::internal_reference;
192 using internal_const_element_type =
193 typename detail::BruidhinnTraits<Element>::internal_const_value_type;
201 using element_type =
typename detail::BruidhinnTraits<Element>::value_type;
208 typename detail::BruidhinnTraits<Element>::const_reference;
214 typename detail::BruidhinnTraits<Element>::reference;
246 using One =
typename Traits::One;
252 using Swap =
typename Traits::Swap;
260 internal_element_type _one;
261 detail::StaticTriVector2<point_type, N> _orbits;
262 detail::Array2<bool, N> _orbits_lookup;
263 detail::StaticTriVector2<internal_element_type, N> _strong_gens;
264 mutable internal_element_type _tmp_element1;
265 mutable internal_element_type _tmp_element2;
266 detail::Array2<internal_element_type, N> _transversal;
267 detail::Array2<internal_element_type, N> _inversal;
427 throw_if_bad_depth(depth);
452 return _strong_gens.size(depth);
497 return this->to_external_const(_strong_gens.at(depth, index));
523 return this->to_external_const(_transversal[depth][pt]);
571 return this->to_external_const(_inversal[depth][pt]);
618 return _orbits_lookup[depth][pt];
638 throw_if_bad_depth(depth);
639 throw_if_point_gt_degree(pt);
657 return _strong_gens.size(0) == 0;
696 internal_sift(this->to_internal(x));
711 throw_if_bad_degree(x);
728 this->to_external(_tmp_element2) = x;
730 internal_sift(_tmp_element2);
731 return this->to_external_const(_tmp_element2);
748 throw_if_bad_degree(x);
797 noexcept(noexcept(this->to_external_const(_one))) {
798 return this->to_external_const(_one);
869 throw_if_bad_depth(index);
908 bool is_valid_degree(
point_type x)
const noexcept {
910#ifdef LIBSEMIGROUPS_HPCOMBI_ENABLED
917 std::string_view arg_pos =
"1st")
const;
919 void throw_if_bad_depth(
size_t depth,
920 std::string_view arg_pos =
"1st")
const;
923 std::string_view arg_pos =
"1st")
const;
925 void throw_if_point_not_in_orbit(
index_type depth,
927 std::string_view depth_arg_pos =
"1st",
928 std::string_view pt_arg_pos =
"2nd")
const;
934 bool internal_equal_to(internal_const_element_type x,
935 internal_const_element_type y)
const
937 EqualTo()(this->to_external_const(x),
938 this->to_external_const(
939 y)) &&
noexcept(this->to_external_const(x)))) {
940 return EqualTo()(this->to_external_const(x), this->to_external_const(y));
944 void init_strong_gens_traversal_inversal(
SchreierSims const& that);
945 void free_strong_gens_traversal_inversal();
949 void orbit_add_gen(
index_type depth, internal_element_type gen);
951 internal_element_type x,
955 index_type internal_sift(internal_reference x)
const;
957 typename domain_type::const_iterator
958 first_non_fixed_point(internal_const_element_type x)
const {
959 auto const& y = this->to_external_const(x);
960 return std::find_if(_domain.cbegin(), _domain.cend(), [&y](
auto pt) {
961 return pt != Action()(pt, y);
996 template <
size_t N,
typename Po
int,
typename Element,
typename Traits>
1015 template <
size_t N,
typename Po
int,
typename Element,
typename Traits>
1018 size_t max_width = 72);
1021#include "schreier-sims.tpp"
A deterministic version of the Schreier-Sims algorithm acting on a small number of points.
Definition schreier-sims.hpp:176
SchreierSims(SchreierSims &&)
Default move constructor.
const_element_reference strong_generator_no_checks(index_type depth, index_type index) const
Get a strong generator.
Definition schreier-sims.hpp:496
bool orbit_lookup(index_type depth, point_type pt) const
Check if a point is in the orbit of a basepoint.
Definition schreier-sims.hpp:637
bool currently_contains(const_element_reference x) const
Test membership of an element without running.
void run()
Run the Schreier-Sims algorithm.
const_element_reference generator(index_type index) const
Get a generator.
Definition schreier-sims.hpp:373
const_element_reference sift(const_element_reference x) const
Sift an element through the stabiliser chain.
Definition schreier-sims.hpp:747
const_element_reference transversal_element_no_checks(index_type depth, point_type pt) const
Get a transversal element.
Definition schreier-sims.hpp:522
typename Traits::EqualTo EqualTo
Adapter for testing equality.
Definition schreier-sims.hpp:240
void sift_inplace(element_reference x) const
Sift an element through the stabiliser chain in-place.
Definition schreier-sims.hpp:710
size_t base_size() const noexcept
Get the size of the current base.
Definition schreier-sims.hpp:885
size_t number_of_strong_generators_no_checks(index_type depth) const
The number of strong generators at a given depth.
Definition schreier-sims.hpp:451
size_t number_of_strong_generators(index_type depth) const
The number of strong generators at a given depth.
Definition schreier-sims.hpp:426
typename detail::BruidhinnTraits< Element >::reference element_reference
Type of a reference to the elements.
Definition schreier-sims.hpp:213
bool finished() const noexcept
Check if the stabiliser chain is fully enumerated.
Definition schreier-sims.hpp:814
typename Traits::One One
Adapter for the identity element of the given type.
Definition schreier-sims.hpp:246
point_type base(index_type index) const
Get a base point.
Definition schreier-sims.hpp:868
const_element_reference generator_no_checks(index_type index) const
Get a generator.
Definition schreier-sims.hpp:393
typename Traits::Degree Degree
Adapter for the degree of an element.
Definition schreier-sims.hpp:237
typename detail::BruidhinnTraits< Element >::value_type element_type
Type of the elements.
Definition schreier-sims.hpp:201
void sift_inplace_no_checks(element_reference x) const
Sift an element through the stabiliser chain in-place.
Definition schreier-sims.hpp:694
typename Traits::index_type index_type
Type of indices.
Definition schreier-sims.hpp:229
uint64_t size()
Returns the size of the group represented by this.
typename Traits::Inverse Inverse
Adapter for the inverse of an element.
Definition schreier-sims.hpp:243
bool empty() const
Check if any generators have been added so far.
Definition schreier-sims.hpp:656
const_element_reference inverse_transversal_element_no_checks(index_type depth, point_type pt) const
Get an inverse of a transversal element.
Definition schreier-sims.hpp:569
typename Traits::Action Action
Alias for Traits::Action.
Definition schreier-sims.hpp:234
const_element_reference transversal_element(index_type depth, point_type pt) const
Get a transversal element.
const_element_reference sift_no_checks(const_element_reference x) const
Sift an element through the stabiliser chain.
Definition schreier-sims.hpp:727
Point point_type
Type of the points acted on.
Definition schreier-sims.hpp:219
SchreierSims()
Default constructor.
bool add_generator(const_element_reference x)
Add a generator.
const_element_reference one() const noexcept(noexcept(this->to_external_const(_one)))
Returns a const reference to the identity.
Definition schreier-sims.hpp:796
typename Traits::domain_type domain_type
Type of the object containing all points acted on.
Definition schreier-sims.hpp:224
bool add_generator_no_checks(const_element_reference x)
Add a generator.
point_type base_no_checks(index_type index) const
Get a base point.
Definition schreier-sims.hpp:851
typename Traits::Swap Swap
Adapter for swapping.
Definition schreier-sims.hpp:252
size_t number_of_generators() const
The number of generators.
bool orbit_lookup_no_checks(index_type depth, point_type pt) const
Check if a point is in the orbit of a basepoint.
Definition schreier-sims.hpp:616
typename Traits::Product Product
Adapter for the product of two elements.
Definition schreier-sims.hpp:249
bool contains(const_element_reference x)
Test membership of an element.
uint64_t current_size() const
Returns the size of the group represented by this, without running.
SchreierSims & init()
Reset to the trivial group.
typename detail::BruidhinnTraits< Element >::const_reference const_element_reference
Type of a const reference to the elements.
Definition schreier-sims.hpp:207
SchreierSims & operator=(SchreierSims const &that)
Default copy assignment.
const_element_reference strong_generator(index_type depth, index_type index) const
Get a strong generator.
void add_base_point(point_type pt)
Add a base point to the stabiliser chain.
SchreierSims(SchreierSims const &that)
Default copy constructor.
const_element_reference inverse_transversal_element(index_type depth, point_type pt) const
Get an inverse of a transversal element.
SchreierSims & operator=(SchreierSims &&)
Default move assignment.
std::string to_human_readable_repr(AhoCorasick const &ac)
Return a string representation.
typename detail::LeastPermHelper< N >::type LeastPerm
Type of perms using the least memory for a given degree.
Definition transf.hpp:2408
Namespace for SchreierSims helper functions.
Definition schreier-sims.hpp:970
void intersection(SchreierSims< N, Point, Element, Traits > &T, SchreierSims< N, Point, Element, Traits > &S1, SchreierSims< N, Point, Element, Traits > &S2)
Find the intersection of two permutation groups.
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
Adapter for the degree of an element.
Definition adapters.hpp:159
Adapter for testing equality.
Definition adapters.hpp:413
Adapter for the value of a right action.
Definition adapters.hpp:392
Adapter for the inverse of an element.
Definition adapters.hpp:319
Adapter for the identity element of the given type.
Definition adapters.hpp:246
Adapter for the product of two elements.
Definition adapters.hpp:284
Traits class for use with the class template SchreierSims.
Definition schreier-sims.hpp:99
libsemigroups::Swap< element_type > Swap
Adapter for swapping.
Definition schreier-sims.hpp:140
detail::IntRange< Point > domain_type
Type of the object containing all points acted on.
Definition schreier-sims.hpp:108
libsemigroups::One< element_type > One
Adapter for the identity element of the given type.
Definition schreier-sims.hpp:134
libsemigroups::ImageRightAction< element_type, Point > Action
Adapter for the value of a right action.
Definition schreier-sims.hpp:122
Element element_type
Type of the elements.
Definition schreier-sims.hpp:119
libsemigroups::Inverse< element_type > Inverse
Adapter for increasing the degree of an element.
Definition schreier-sims.hpp:131
size_t index_type
The type of indices to be used by a SchreierSims instance.
Definition schreier-sims.hpp:103
libsemigroups::EqualTo< element_type > EqualTo
Adapter for testing equality.
Definition schreier-sims.hpp:128
Point point_type
Type of the points acted on.
Definition schreier-sims.hpp:114
libsemigroups::Product< element_type > Product
Adapter for the product of two elements.
Definition schreier-sims.hpp:137
libsemigroups::Degree< element_type > Degree
Adapter for the degree of an element.
Definition schreier-sims.hpp:125
std::conditional_t< N >=0x100000000, uint64_t, std::conditional_t< N >=0x10000, uint32_t, std::conditional_t< N >=0x100, uint16_t, uint8_t > > > type
Definition types.hpp:89
Adapter for swapping.
Definition adapters.hpp:666