Skip to content

Commit

Permalink
Add repr for InversePresentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph-Edwards committed Jul 2, 2024
1 parent a8c97e6 commit 2587b35
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/libsemigroups/presentation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2346,6 +2346,20 @@ namespace libsemigroups {
template <typename Word>
std::string to_human_readable_repr(Presentation<Word> const& p);

//! \ingroup presentations_group
//!
//! \brief Return a human readable representation of an InversePresentation.
//!
//! Return a human readable representation of an InversePresentation.
//!
//! \tparam Word the type of the words in the InversePresentation.
//! \param p the InversePresentation.
//!
//! \exceptions
//! \no_libsemigroups_except
template <typename Word>
std::string to_human_readable_repr(InversePresentation<Word> const& p);

namespace detail {
template <typename T>
struct IsPresentationHelper : std::false_type {};
Expand Down
26 changes: 26 additions & 0 deletions include/libsemigroups/presentation.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,32 @@ namespace libsemigroups {
return out;
}

template <typename Word>
std::string to_human_readable_repr(InversePresentation<Word> const& p) {
size_t alphabet_size = p.alphabet().size();
size_t n_rules = p.rules.size() / 2;
std::string out = "<";
if (p.contains_empty_word()) {
out += "Monoid ";
} else {
out += "Semigroup ";
}
out += "Presentation with inverses on ";
if (alphabet_size == 1) {
out += "1 letter ";
} else {
out += std::to_string(alphabet_size) + " letters ";
}
out += "with ";
if (n_rules == 1) {
out += "1 rule";
} else {
out += std::to_string(n_rules) + " rules";
}
out += ">";
return out;
}

template <typename Word>
InversePresentation<Word>&
InversePresentation<Word>::inverses_no_checks(word_type const& w) {
Expand Down

0 comments on commit 2587b35

Please sign in to comment.