libsemigroups  v3.6.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-2026 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
34namespace libsemigroups {
35
36 template <typename>
37 class Kambites; // forward decl
38
39 template <typename>
40 class ToddCoxeter; // forward decl
41
42 template <typename>
43 class Stephen; // forward decl
44
52
60
62 // FroidurePin -> Presentation
64
96 template <typename Result>
97 auto to(FroidurePinBase& fp) -> std::enable_if_t<
98 std::is_same_v<Presentation<typename Result::word_type>, Result>,
99 Result>;
100
102 // KnuthBendix -> Presentation
104
144 template <typename Result,
145 typename WordIn,
146 typename Rewriter,
147 typename ReductionOrder>
148 auto to(KnuthBendix<WordIn, Rewriter, ReductionOrder>& kb)
149 -> std::enable_if_t<
150 std::is_same_v<Presentation<typename Result::word_type>, Result>,
151 Result>;
152
187 template <template <typename...> typename Thing,
188 typename Word,
189 typename Rewriter,
190 typename ReductionOrder>
191 auto to(KnuthBendix<Word, Rewriter, ReductionOrder>& kb)
192 -> std::enable_if_t<std::is_same_v<Thing<Word>, Presentation<Word>>,
194 return to<Presentation<Word>>(kb);
195 }
196
198 // Kambites -> Presentation
200
226 template <typename Result, typename Word>
227 auto to(Kambites<Word>& k) -> std::enable_if_t<
228 std::is_same_v<Presentation<typename Result::word_type>, Result>
229 && !std::is_same_v<typename Result::word_type, Word>,
230 Result> {
231 return v4::to<Result>(k.presentation());
232 }
233
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 const&> {
261 return k.presentation();
262 }
263
265 // ToddCoxeter -> Presentation
267
293 template <typename Result, typename Word>
294 auto to(ToddCoxeter<Word>& tc) -> std::enable_if_t<
295 std::is_same_v<Presentation<typename Result::word_type>, Result>
296 && !std::is_same_v<typename Result::word_type, Word>,
297 Result> {
298 return v4::to<Result>(tc.presentation());
299 }
300
323 template <typename Result, typename Word>
324 auto to(ToddCoxeter<Word>& tc) -> std::enable_if_t<
325 std::is_same_v<Presentation<typename Result::word_type>, Result>
326 && std::is_same_v<typename Result::word_type, Word>,
327 Result const&> {
328 return tc.presentation();
329 }
330
332 // Congruence -> Presentation
334
360 template <typename Result, typename Word>
361 auto to(Congruence<Word>& c) -> std::enable_if_t<
362 std::is_same_v<Presentation<typename Result::word_type>, Result>
363 && !std::is_same_v<typename Result::word_type, Word>,
364 Result> {
365 return v4::to<Result>(c.presentation());
366 }
367
390 template <typename Result, typename Word>
391 auto to(Congruence<Word>& c) -> std::enable_if_t<
392 std::is_same_v<Presentation<typename Result::word_type>, Result>
393 && std::is_same_v<typename Result::word_type, Word>,
394 Result const&> {
395 return c.presentation();
396 }
397
399 // Stephen -> Presentation
401
426 template <typename Result, typename PresentationType>
427 auto to(Stephen<PresentationType>& s) -> std::enable_if_t<
428 std::is_same_v<Presentation<typename Result::word_type>, Result>,
429 Result> {
430 return v4::to<Result>(s.presentation());
431 }
432
434 // Presentation + function -> Presentation
436
475 template <typename Result, typename Word, typename Func>
476 [[deprecated]] auto to(Presentation<Word> const& p, Func&& f)
477 -> std::enable_if_t<
478 std::is_same_v<Presentation<typename Result::word_type>, Result>,
479 Result> {
480 return v4::to<Result>(p, f);
481 }
482
484 // InversePresentation + function -> InversePresentation
486
528 template <typename Result, typename Word, typename Func>
529 [[deprecated]] auto
530 to(InversePresentation<Word> const& ip, Func&& f) -> std::enable_if_t<
531 std::is_same_v<InversePresentation<typename Result::word_type>, Result>,
532 Result> {
533 return v4::to<Result>(ip, f);
534 }
535
537 // Presentation -> Presentation
539
575 template <typename Result, typename Word>
576 [[deprecated]] auto to(Presentation<Word> const& p) -> std::enable_if_t<
577 std::is_same_v<Presentation<typename Result::word_type>, Result>
578 && !std::is_same_v<typename Result::word_type, Word>,
579 Result> {
580 return v4::to<Result>(p);
581 }
582
613 template <typename Result, typename Word>
614 [[deprecated]] auto to(Presentation<Word> const& p) noexcept
615 -> std::enable_if_t<std::is_same_v<Presentation<Word>, Result>,
616 Result const&> {
617 return v4::to<Result>(p);
618 }
619
621 // InversePresentation -> InversePresentation
623
661 template <typename Result, typename Word>
662 [[deprecated]] auto
663 to(InversePresentation<Word> const& ip) noexcept -> std::enable_if_t<
664 std::is_same_v<InversePresentation<typename Result::word_type>, Result>
665 && !std::is_same_v<Word, typename Result::word_type>,
666 Result> {
667 return v4::to<Result>(ip);
668 }
669
701 template <typename Result, typename Word>
702 [[deprecated]] auto to(InversePresentation<Word> const& ip) noexcept
703 -> std::enable_if_t<std::is_same_v<InversePresentation<Word>, Result>,
704 Result const&> {
705 return v4::to<Result>(ip);
706 }
707
709 // Presentation -> InversePresentation
711
743 // \note The parameter \p p must not be an `InversePresentation`, otherwise
744 // a compilation error is thrown.
745 // NOTE: not sure this is true anymore so just leaving it out
746 template <template <typename...> typename Thing, typename Word>
747 [[deprecated]] auto to(Presentation<Word> const& p) -> std::enable_if_t<
748 std::is_same_v<InversePresentation<Word>, Thing<Word>>,
750 return v4::to<InversePresentation>(p);
751 }
752} // namespace libsemigroups
753
754#include "to-presentation.tpp"
755
756#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:3220
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
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.