Skip to content

Commit

Permalink
Add TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell committed Dec 13, 2024
1 parent 747d480 commit 8f4d1ce
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 46 deletions.
50 changes: 31 additions & 19 deletions include/libsemigroups/sims.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,8 @@ namespace libsemigroups {
//! * \ref long_rule_length
//! * \ref number_of_threads
//!
//! The return value of this function can be used to
//! initialise another Sims1, Sims2, RepOrc, or
//! MinimalRepOrc with these settings.
//! The return value of this function can be used to initialise another
//! Sims1, Sims2, RepOrc, or MinimalRepOrc with these settings.
//!
//! \returns A const reference to SimsSettings.
//!
Expand Down Expand Up @@ -524,13 +523,13 @@ namespace libsemigroups {
//! \noexcept
//!
//! \warning
//! The value returned by this
//! function is not guaranteed be the same as the presentation that was used
//! to construct the object! A Sims1 or Sims2 object requires the generators
//! of the defining presentation \f$\mathcal{P}\f$ to be \f$\{0, \ldots, n -
//! 1\}\f$ where \f$n\f$ is the size of the alphabet of \f$\mathcal{P}\f$.
//! Every occurrence of every generator \c a in the presentation \c p used
//! to construct a Sims1 or Sims2 instance is replaced by `p.index(a)`.
//! The value returned by this function is not guaranteed be the same as
//! the presentation that was used to construct the object! A Sims1 or Sims2
//! object requires the generators of the defining presentation
//! \f$\mathcal{P}\f$ to be \f$\{0, \ldots, n - 1\}\f$ where \f$n\f$ is the
//! size of the alphabet of \f$\mathcal{P}\f$. Every occurrence of every
//! generator \c a in the presentation \c p used to construct a Sims1 or
//! Sims2 instance is replaced by `p.index(a)`.
[[nodiscard]] Presentation<word_type> const& presentation() const noexcept {
return _presentation;
}
Expand Down Expand Up @@ -602,7 +601,7 @@ namespace libsemigroups {
return _longs_begin;
}

//! Clear the set of long rules.
//! \brief Clear the set of long rules.
//!
//! \returns A reference to \c this.
//!
Expand Down Expand Up @@ -660,7 +659,7 @@ namespace libsemigroups {
return _pruners;
}

//! Add a pruner to the search tree.
//! \brief Add a pruner to the search tree.
//!
//! \param func an rvalue reference to a pruner function.
//!
Expand All @@ -679,7 +678,7 @@ namespace libsemigroups {
return static_cast<Subclass&>(*this);
}

//! Clear the set of pruners.
//! \brief Clear the set of pruners.
//!
//! \returns A reference to \c this.
//!
Expand Down Expand Up @@ -755,6 +754,7 @@ namespace libsemigroups {
//! `validate_word(rhs)` throws.
//!
//! \sa \ref include
// TODO(0) to helper
Subclass& include(word_type const& lhs, word_type const& rhs) {
return include_exclude(lhs, rhs, _include);
}
Expand Down Expand Up @@ -786,14 +786,14 @@ namespace libsemigroups {
//! \warning
//! This function replaces all previously set `include` pairs with
//! those found in \p c.
// TODO(1) move to helper namespace
// TODO(0) move to helper namespace
template <typename Container>
Subclass& include(Container const& c) {
include(std::begin(c), std::end(c));
return static_cast<Subclass&>(*this);
}

//! Clear the set of included words.
//! \brief Clear the set of included words.
//!
//! \returns A reference to \c this.
//!
Expand Down Expand Up @@ -872,6 +872,7 @@ namespace libsemigroups {
//! `validate_word(rhs)` throws.
//!
//! \sa \ref exclude
// TODO(0) to helper
Subclass& exclude(word_type const& lhs, word_type const& rhs) {
add_exclude_pruner();
return include_exclude(lhs, rhs, _exclude);
Expand Down Expand Up @@ -904,19 +905,20 @@ namespace libsemigroups {
//! \warning
//! This function replaces all previously set `exclude` pairs with
//! those found in \p c.
// TODO(1) move to helper namespace
// TODO(0) move to helper namespace
template <typename Container>
Subclass& exclude(Container const& c) {
exclude(std::begin(c), std::end(c));
return static_cast<Subclass&>(*this);
}

//! Clear the set of excluded words.
//! \brief Clear the set of excluded words.
//!
//! \returns A reference to \c this.
//!
//! \exceptions
//! \no_libsemigroups_except
// TODO(0) to tpp file
Subclass& clear_exclude() {
if (_exclude_pruner_index != UNDEFINED) {
_exclude.clear();
Expand All @@ -926,8 +928,6 @@ namespace libsemigroups {
return static_cast<Subclass&>(*this);
}

// TODO(2) (later) ranges version of include/exclude?

//! \brief Get the current stats object.
//!
//! Returns a const reference to the current stats object.
Expand Down Expand Up @@ -989,6 +989,7 @@ namespace libsemigroups {
Iterator last,
std::vector<word_type>& include_or_exclude);

// TODO(0) remove
Subclass& include_exclude(word_type const& lhs,
word_type const& rhs,
std::vector<word_type>& include_or_exclude);
Expand Down Expand Up @@ -2296,6 +2297,8 @@ namespace libsemigroups {
WordGraph<Node> const& wg);

//! No doc
// TODO(0) out of line
// TODO(0) rename throw_if
template <typename Node>
void validate_right_congruence(Presentation<word_type> const& p,
WordGraph<Node> const& wg) {
Expand Down Expand Up @@ -2349,6 +2352,7 @@ namespace libsemigroups {
//! Returns `true` if the word graph \p wg defines a two-sided
//! congruence on the semigroup or monoid defined by \p p and `false`
//! otherwise.
// TODO(0) out of line
template <typename Node>
bool is_two_sided_congruence(Presentation<word_type> const& p,
WordGraph<Node> const& wg) {
Expand All @@ -2359,6 +2363,7 @@ namespace libsemigroups {
}

//! No doc
// TODO(0) out of line
template <typename Node>
void validate_two_sided_congruence(Presentation<word_type> const& p,
WordGraph<Node> const& wg) {
Expand Down Expand Up @@ -2467,6 +2472,7 @@ namespace libsemigroups {
return cbegin_two_sided_generating_pairs_no_checks(p, wg);
}

// TODO(0) many of the functions in below are missing a \returns item
//! \ingroup congruences_group
//!
//! \brief Get an iterator pointing to one after the last right congruence
Expand Down Expand Up @@ -2633,6 +2639,7 @@ namespace libsemigroups {
//!
//! \throws LibsemigroupsException if the argument \p wg does not define a
//! right congruence on the free monoid.
// TODO(0) out of line
template <typename Node>
rx::iterator_range<const_rcgp_iterator>
right_generating_pairs(WordGraph<Node> const& wg) {
Expand Down Expand Up @@ -2858,6 +2865,8 @@ namespace libsemigroups {
//! \warning
//! This method does not verify if \p forbid contains trivial pairs or not.
// TODO(2): Construct from std::vector<std::string>
// TODO(0) construct from iterators, and move word_type version of to helper
// namespace
explicit SimsRefinerFaithful(std::vector<word_type> const& forbid)
: _forbid(forbid) {}

Expand All @@ -2871,6 +2880,8 @@ namespace libsemigroups {
//!
//! \warning
//! This method does not verify if \p forbid contains trivial pairs or not.
// TODO(0) construct from iterators, and move word_type version of to helper
// namespace
SimsRefinerFaithful& init(std::vector<word_type> const& forbid) {
_forbid.clear();
_forbid = forbid;
Expand Down Expand Up @@ -3014,6 +3025,7 @@ namespace libsemigroups {
//! terminate on certain inputs.
//!
//! \sa presentation(Presentation<std::string> const&)
// TODO(0) to tpp
SimsRefinerIdeals& init(Presentation<std::string> const& p) {
_presentation = to_presentation<word_type>(p);
_knuth_bendices[0].init(congruence_kind::twosided, _presentation).run();
Expand Down
12 changes: 4 additions & 8 deletions include/libsemigroups/sims.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace libsemigroups {
return static_cast<Subclass&>(*this);
}

// TODO(0) is this ifndef required here?
#ifndef PARSED_BY_DOXYGEN
template <typename Subclass>
template <typename OtherSubclass>
Expand All @@ -54,7 +55,7 @@ namespace libsemigroups {
_pruners = that.pruners();
return *this;
}
#endif /* PARSED_BY_DOXYGEN */
#endif // PARSED_BY_DOXYGEN

template <typename Subclass>
template <typename Word>
Expand Down Expand Up @@ -173,14 +174,9 @@ namespace libsemigroups {
wg.number_of_active_nodes());
tc.init(congruence_kind::onesided, p, copy);
todd_coxeter::add_generating_pair(tc, wx, wy);
// LIBSEMIGROUPS_ASSERT(tc.word_graph().number_of_nodes()
// TODO(1) uncomment these assertions when ToddCoxeter initialization
// is fixed LIBSEMIGROUPS_ASSERT(tc.word_graph().number_of_nodes()
// == wg.number_of_active_nodes());
// fmt::print("x = {}, y = {}\n", x, y);
// fmt::print("wx = {}, wy = {}\n", wx, wy);
// std::cout << copy << std::endl;
// fmt::print("tc.number_of_classes() == {}\n",
// tc.number_of_classes()); fmt::print("copy.number_of_nodes() ==
// {}\n", copy.number_of_nodes());
// LIBSEMIGROUPS_ASSERT(tc.number_of_classes()
// < wg.number_of_active_nodes());
if (tc.number_of_classes() > 1) {
Expand Down
28 changes: 9 additions & 19 deletions src/sims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@

#include "libsemigroups/sims.hpp"

#include <algorithm> // for fill, reverse
#include <functional> // for function, ref
#include <memory> // for unique_ptr, make_unique, swap
#include <string> // for basic_string, string, operator+
#include <thread> // for thread, yield
#include <tuple> // for _Swallow_assign, ignore
#include <unordered_map> // for operator==, operator!=
#include <utility> // for move, swap, pair
#include <algorithm> // for fill, reverse
#include <functional> // for function, ref
#include <memory> // for unique_ptr, make_unique, swap
#include <string> // for basic_string, string, operator+
#include <thread> // for thread, yield
#include <tuple> // for _Swallow_assign, ignore
#include <utility> // for move, swap, pair

#include "libsemigroups/constants.hpp" // for operator!=, ope...
#include "libsemigroups/debug.hpp" // for LIBSEMIGROUPS_A...
Expand All @@ -44,15 +43,13 @@
#include "libsemigroups/froidure-pin.hpp" // for FroidurePin
#include "libsemigroups/knuth-bendix.hpp" // for KnuthBendix, to_present...
#include "libsemigroups/presentation.hpp" // for Presentation
#include "libsemigroups/ranges.hpp" // for shortlex_compare
#include "libsemigroups/runner.hpp" // for delta, Reporter
#include "libsemigroups/to-froidure-pin.hpp" // for to_word_graph
#include "libsemigroups/transf.hpp" // for Transf, one
#include "libsemigroups/types.hpp" // for congruence_kind
#include "libsemigroups/word-graph.hpp" // for follow_path_no_...

#include "libsemigroups/detail/felsch-graph.hpp" // for FelschGraph
#include "libsemigroups/detail/iterator.hpp" // for operator+
#include "libsemigroups/detail/report.hpp" // for report_default
#include "libsemigroups/detail/stl.hpp" // for JoinThreads
#include "libsemigroups/detail/string.hpp" // for group_digits
Expand Down Expand Up @@ -1522,13 +1519,13 @@ namespace libsemigroups {

LIBSEMIGROUPS_ASSERT(detail::this_threads_id()
< std::thread::hardware_concurrency() + 1);
// TODO(1) change this to be const& when we have const_contains for knuth
// TODO(0) change this to be const& when we have const_contains for knuth
// bendix
auto& kb = _knuth_bendices[detail::this_threads_id()];
for (auto const& p : right_generating_pairs_no_checks(wg)) {
auto const& u = p.first;
auto const& v = p.second;
// TODO(1) change this to be const_contains for knuth
// TODO(0) change this to be const_contains for knuth
// bendix when we have it
if (!knuth_bendix::contains(kb, u, v)) {
auto beta
Expand Down Expand Up @@ -1623,13 +1620,6 @@ namespace libsemigroups {

} // namespace helper

// template <typename Subclass>
// [[nodiscard]] std::string
// to_human_readable_repr(SimsSettings<Subclass> const& x) {
// return fmt::format("<SimsSettings {}>",
// helper::sims_to_human_readable_repr_helper(x, ""));
// }

[[nodiscard]] std::string to_human_readable_repr(Sims1 const& x) {
return fmt::format("<Sims1 {}>",
helper::sims_to_human_readable_repr_helper(x, ""));
Expand Down

0 comments on commit 8f4d1ce

Please sign in to comment.