libsemigroups  v3.3.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
to-presentation.hpp
1//
2// libsemigroups - C++ library for semigroups and monoids
3// Copyright (C) 2023-2025 James D. Mitchell + James W. Swent
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17//
18
19#ifndef LIBSEMIGROUPS_TO_PRESENTATION_HPP_
20#define LIBSEMIGROUPS_TO_PRESENTATION_HPP_
21
22#include <algorithm> // for transform, rotate
23#include <string> // for basic_string
24#include <type_traits> // for is_same_v, ena...
25#include <utility> // for move
26#include <vector> // for vector
27
28#include "froidure-pin-base.hpp" // for FroidurePinBase
29#include "knuth-bendix-class.hpp" // for KnuthBendix
30#include "presentation.hpp" // for Presentation
31#include "word-range.hpp" // for human_readable...
32
33// TODO(1): Make as many of these functions const as possible
34// TODO(1): Remove the intentional typos from doxygen declarations once
35// issue doxygen issue #11787 is merged into release
36namespace libsemigroups {
37
38 template <typename>
39 class Kambites; // forward decl
40
41 template <typename>
42 class ToddCoxeter; // forward decl
43
44 template <typename>
45 class Stephen; // forward decl
46
54
62
64 // FroidurePin -> Presentation
66
98 template <typename Result>
99 auto to(FroidurePinBase& fp) -> std::enable_if_t<
100 std::is_same_v<Presentation<typename Result::word_type>, Result>,
101 Result>;
102
104 // KnuthBendix -> Presentation
106
146 template <typename Result,
147 typename WordIn,
148 typename Rewriter,
149 typename ReductionOrder>
150 auto to(KnuthBendix<WordIn, Rewriter, ReductionOrder>& kb)
151 -> std::enable_if_t<
152 std::is_same_v<Presentation<typename Result::word_type>, Result>,
153 Result>;
154
189#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
190 // FIXME(1) this is the same hack as elsewhere (deliberately introducing a
191 // typo) because Doxygen conflates functions with trailing return type but the
192 // same name and signature.
193 template <template <typename...> typename Thing,
194 typename Word,
195 typename Rewriter typename ReductionOrder>
196 auto to(KnutBendix<Word, Rewriter, ReductionOrder>& kb)
197 -> std::enable_if_t<std::is_same_v<Thing<Word>, Presentation<Word>>,
199#else
200 template <template <typename...> typename Thing,
201 typename Word,
202 typename Rewriter,
203 typename ReductionOrder>
204 auto to(KnuthBendix<Word, Rewriter, ReductionOrder>& kb)
205 -> std::enable_if_t<std::is_same_v<Thing<Word>, Presentation<Word>>,
207 return to<Presentation<Word>>(kb);
208 }
209#endif
210
212 // Kambites -> Presentation
214
246#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
247 // FIXME(1) this is the same hack as elsewhere (deliberately introducing a
248 // typo) because Doxygen conflates functions with trailing return type but the
249 // same name and signature.
250 template <typename Result, typename Word>
251 auto to(Kambtes<Word>& k) -> std::enable_if_t<
252 std::is_same_v<Presentation<typename Result::word_type>, Result>
253 && !std::is_same_v<typename Result::word_type, Word>,
254 Result>;
255#else
256 template <typename Result, typename Word>
257 auto to(Kambites<Word>& k) -> std::enable_if_t<
258 std::is_same_v<Presentation<typename Result::word_type>, Result>
259 && !std::is_same_v<typename Result::word_type, Word>,
260 Result> {
261 return v4::to<Result>(k.presentation());
262 }
263
264 // This function is documented above because Doxygen conflates these two
265 // functions
266 template <typename Result, typename Word>
267 auto to(Kambites<Word>& k) -> std::enable_if_t<
268 std::is_same_v<Presentation<typename Result::word_type>, Result>
269 && std::is_same_v<typename Result::word_type, Word>,
270 Result const&> {
271 return k.presentation();
272 }
273#endif
274
276 // ToddCoxeter -> Presentation
278
310#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
311 // FIXME(1) this is the same hack as elsewhere (deliberately introducing a
312 // typo) because Doxygen conflates functions with trailing return type but the
313 // same name and signature.
314 template <typename Result, typename Word>
315 auto to(ToddCoxter<Word>& tc) -> std::enable_if_t<
316 std::is_same_v<Presentation<typename Result::word_type>, Result>
317 && !std::is_same_v<typename Result::word_type, Word>,
318 Result>;
319#else
320 template <typename Result, typename Word>
321 auto to(ToddCoxeter<Word>& tc) -> std::enable_if_t<
322 std::is_same_v<Presentation<typename Result::word_type>, Result>
323 && !std::is_same_v<typename Result::word_type, Word>,
324 Result> {
325 return v4::to<Result>(tc.presentation());
326 }
327
328 // This function is documented above because Doxygen conflates these two
329 // functions
330 template <typename Result, typename Word>
331 auto to(ToddCoxeter<Word>& tc) -> std::enable_if_t<
332 std::is_same_v<Presentation<typename Result::word_type>, Result>
333 && std::is_same_v<typename Result::word_type, Word>,
334 Result const&> {
335 return tc.presentation();
336 }
337#endif
338
340 // Congruence -> Presentation
342
374#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
375 // FIXME(1) this is the same hack as elsewhere (deliberately introducing a
376 // typo) because Doxygen conflates functions with trailing return type but the
377 // same name and signature.
378 template <typename Result, typename Word>
379 auto to(Congrence<Word>& c) -> std::enable_if_t<
380 std::is_same_v<Presentation<typename Result::word_type>, Result>
381 && !std::is_same_v<typename Result::word_type, Word>,
382 Result>;
383#else
384 template <typename Result, typename Word>
385 auto to(Congruence<Word>& c) -> std::enable_if_t<
386 std::is_same_v<Presentation<typename Result::word_type>, Result>
387 && !std::is_same_v<typename Result::word_type, Word>,
388 Result> {
389 return v4::to<Result>(c.presentation());
390 }
391
392 // This function is documented above because Doxygen conflates these two
393 // functions
394 template <typename Result, typename Word>
395 auto to(Congruence<Word>& c) -> std::enable_if_t<
396 std::is_same_v<Presentation<typename Result::word_type>, Result>
397 && std::is_same_v<typename Result::word_type, Word>,
398 Result const&> {
399 return c.presentation();
400 }
401#endif
402
404 // Stephen -> Presentation
406
431 template <typename Result, typename PresentationType>
432 auto to(Stephen<PresentationType>& s) -> std::enable_if_t<
433 std::is_same_v<Presentation<typename Result::word_type>, Result>,
434 Result> {
435 return v4::to<Result>(s.presentation());
436 }
437
439 // Presentation + function -> Presentation
441
480 template <typename Result, typename Word, typename Func>
481 [[deprecated]] auto to(Presentation<Word> const& p, Func&& f)
482 -> std::enable_if_t<
483 std::is_same_v<Presentation<typename Result::word_type>, Result>,
484 Result> {
485 return v4::to<Result>(p, f);
486 }
487
489 // InversePresentation + function -> InversePresentation
491
533 template <typename Result, typename Word, typename Func>
534 [[deprecated]] auto
535 to(InversePresentation<Word> const& ip, Func&& f) -> std::enable_if_t<
536 std::is_same_v<InversePresentation<typename Result::word_type>, Result>,
537 Result> {
538 return v4::to<Result>(ip, f);
539 }
540
542 // Presentation -> Presentation
544
590 template <typename Result, typename Word>
591 [[deprecated]] auto to(Presentation<Word> const& p) -> std::enable_if_t<
592 std::is_same_v<Presentation<typename Result::word_type>, Result>
593 && !std::is_same_v<typename Result::word_type, Word>,
594 Result> {
595 return v4::to<Result>(p);
596 }
597
598 // This function is documented above because Doxygen conflates these two
599 // functions.
600 template <typename Result, typename Word>
601 [[deprecated]] auto to(Presentation<Word> const& p) noexcept
602 -> std::enable_if_t<std::is_same_v<Presentation<Word>, Result>,
603 Result const&> {
604 return v4::to<Result>(p);
605 }
606
608 // InversePresentation -> InversePresentation
610
658 template <typename Result, typename Word>
659 [[deprecated]] auto
660 to(InversePresentation<Word> const& ip) noexcept -> std::enable_if_t<
661 std::is_same_v<InversePresentation<typename Result::word_type>, Result>
662 && !std::is_same_v<Word, typename Result::word_type>,
663 Result> {
664 return v4::to<Result>(ip);
665 }
666
667 // This function is documented above because Doxygen conflates these two
668 // functions.
669 template <typename Result, typename Word>
670 [[deprecated]] auto to(InversePresentation<Word> const& ip) noexcept
671 -> std::enable_if_t<std::is_same_v<InversePresentation<Word>, Result>,
672 Result const&> {
673 return v4::to<Result>(ip);
674 }
675
677 // Presentation -> InversePresentation
679
711// \note The parameter \p p must not be an `InversePresentation`, otherwise
712// a compilation error is thrown.
713// NOTE: not sure this is true anymore so just leaving it out
714#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
715 // FIXME(1) this is the same hack as elsewhere because Doxygen conflates
716 // functions with trailing return type but the same name and signature.
717 template <template <typename...> typename Thing, typename Word>
718 auto to(Presentation<Word> const& p) -> std::enable_if_t<
719 std::is_same_v<InversePresentation<Word>, Thing<Word>>,
721#else
722 template <template <typename...> typename Thing, typename Word>
723 [[deprecated]] auto to(Presentation<Word> const& p) -> std::enable_if_t<
724 std::is_same_v<InversePresentation<Word>, Thing<Word>>,
726 return v4::to<InversePresentation>(p);
727 }
728#endif
729} // namespace libsemigroups
730
731#include "to-presentation.tpp"
732
733#endif // LIBSEMIGROUPS_TO_PRESENTATION_HPP_
Base class for FroidurePin containing non-element specific data and member functions.
Definition froidure-pin-base.hpp:67
For an implementation of inverse presentations for semigroups or monoids.
Definition presentation.hpp:2735
For an implementation of presentations for semigroups or monoids.
Definition presentation.hpp:103
For constructing the word graph of left factors of a word in an f.p. semigroup.
Definition stephen.hpp:91
Congruence(congruence_kind, Presentation< Word > const &) -> Congruence< Word >
Deduction guide.
Presentation(Presentation< Word > const &) -> Presentation< Word >
Deduction guide.
ToddCoxeter(congruence_kind, Presentation< Word > const &) -> ToddCoxeter< Word >
Deduction guide.
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
auto to(detail::KnuthBendixImpl< Rewriter, ReductionOrder > &kb) -> std::enable_if_t< std::is_same_v< Presentation< typename Result::word_type >, Result >, Result >
No doc.