Skip to content

Commit

Permalink
Classify todos
Browse files Browse the repository at this point in the history
  • Loading branch information
reiniscirpons committed Jan 20, 2025
1 parent e879924 commit b975493
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 32 deletions.
47 changes: 26 additions & 21 deletions include/libsemigroups/stephen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,30 @@
#include "detail/stl.hpp" // for IsStdSharedPtr
#include "detail/word-graph-with-sources.hpp" // for DigraphWithSources

// TODO
// TODO(0)
// * iwyu
// * update reporting to new standard
// * update so that run_for, run_until work properly (at present basically
// run_impl starts again from scratch every time)
// TODO(1)
// * minimal rep (as per Reinis) (named normal_form?)
// * invert() - just swap the initial and accept states and re-standardize
// * idempotent() - just make the accept state = initial state.
// TODO(2)
// * class_of for inverse Stephen (i.e. all walks in the graph through all
// nodes) (not sure how to do this just yet). This is different than
// words_accepted see Corollary 3.2 in Stephen's "Presentations of inverse
// monoids" paper (not thesis).
// * invert() - just swap the initial and accept states and re-standardize
// * idempotent() - just make the accept state = initial state.
// * update reporting to new standard
// * update so that run_for, run_until work properly (at present basically
// run_impl starts again from scratch every time)
// * canonical_form (as per Howie's book)

namespace libsemigroups {

//! Defined in `stephen.hpp`.
//!
//! On this page we describe the functionality in `libsemigroups` relating
//! to Stephen's procedure for finitely presented semigroups. This class
//! implements Stephen's procedure for (possibly) constructing the word graph
//! (WordGraph) corresponding to the left factors of a word in a finitely
//! (\ref WordGraph) corresponding to the left factors of a word in a finitely
//! presented semigroup. The algorithm implemented in this class is closely
//! related to the Todd-Coxeter algorithm (as implemented in \ref
//! ToddCoxeter) and originates in [Applications of automata theory to
Expand Down Expand Up @@ -93,6 +96,7 @@ namespace libsemigroups {
|| std::is_same_v<R, InversePresentation<word_type>>;
}

// TODO (0): finish assert
static_assert(is_valid_presentation<P>(), "TODO");

public:
Expand Down Expand Up @@ -170,9 +174,10 @@ namespace libsemigroups {
init(q);
}

// TODO to tpp
// TODO(0): to tpp
template <typename Q>
Stephen& init(Q const& q) {
// TODO (0): finish assert
static_assert(((IsInversePresentation<P>) == (IsInversePresentation<Q>) )
&& IsPresentation<P> && IsPresentation<Q>,
"TODO");
Expand All @@ -183,7 +188,7 @@ namespace libsemigroups {
}
}

// TODO make private and hid in tpp file
// TODO(0): make private and hide in tpp file
template <typename PP>
static constexpr auto& deref_if_necessary(PP&& p) {
if constexpr (detail::IsStdSharedPtr<std::decay_t<PP>>) {
Expand Down Expand Up @@ -259,10 +264,10 @@ namespace libsemigroups {
//!
//! \exceptions
//! \noexcept
// TODO add a warning that if the value of word is set, then run is called,
// then word is set to another value, then word_graph() is accessed, then
// the returned value doesn't relate to the currently set value. Or better
// still don't have this behaviour
// TODO(0) add a warning that if the value of word is set, then run is
// called, then word is set to another value, then word_graph() is accessed,
// then the returned value doesn't relate to the currently set value. Or
// better still don't have this behaviour
word_graph_type const& word_graph() const noexcept {
return _word_graph;
}
Expand Down Expand Up @@ -291,8 +296,8 @@ namespace libsemigroups {
}

void operator*=(Stephen<P>& y) {
// TODO if one of this and that is finished, then just tack on the linear
// graph.
// TODO(0): if one of this and that is finished, then just tack on the
// linear graph.
this->run();
y.run();
// FIXME _word_graph has two mem fns number_nodes_active (in NodeManager)
Expand Down Expand Up @@ -352,7 +357,7 @@ namespace libsemigroups {
template <typename Word>
Stephen(std::shared_ptr<InversePresentation<Word>>&&)
-> Stephen<std::shared_ptr<InversePresentation<word_type>>>;
// TODO other shared_prt guides?
// TODO(0): other shared_prt guides?

} // namespace libsemigroups
#include "stephen.tpp"
Expand Down Expand Up @@ -415,7 +420,7 @@ namespace libsemigroups {
return paths.source(s.initial_state());
}

// TODO to tpp
// TODO(0): to tpp
template <typename PresentationType>
uint64_t number_of_words_accepted(Stephen<PresentationType>& s,
size_t min = 0,
Expand All @@ -434,7 +439,7 @@ namespace libsemigroups {
return number_of_paths(s.word_graph(), 0, min, max);
}

// TODO to tpp
// TODO(0) to tpp
template <typename P>
Dot dot(Stephen<P>& s) {
Dot result;
Expand Down Expand Up @@ -475,7 +480,7 @@ namespace libsemigroups {
x.word());
}

// TODO to tpp
// TODO(0) to tpp
template <typename PresentationType>
std::ostream& operator<<(std::ostream& os,
Stephen<PresentationType> const& x) {
Expand All @@ -485,14 +490,14 @@ namespace libsemigroups {
// } else {
word = " " + std::to_string(x.word().size()) + " letter word, ";
//}
// TODO use fmt
// TODO(0): use fmt
os << std::string("<Stephen for ") << word << " with "
<< x.word_graph().number_of_nodes() << " nodes, "
<< x.word_graph().number_of_edges() << " edges>";
return os;
}

// TODO reuse the doc from here to end of file
// TODO(0) reuse the doc from here to end of file
//! The return type of \ref cbegin_words_accepted and \ref
//! cend_words_accepted. This is the same as
//! \ref WordGraph::const_pstislo_iterator.
Expand Down
8 changes: 4 additions & 4 deletions include/libsemigroups/stephen.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ namespace libsemigroups {
}

void disjoint_union_inplace_no_checks(StephenGraph const& that) {
// TODO throw exception if that.labels() != this->labels()
// TODO the following requires that this and that are standardized
// TODO(0): throw exception if that.labels() != this->labels()
// TODO(1): the following requires that this and that are standardized
// and that this and that are run to the end
size_t const N = number_of_nodes_active();
// TODO the following 2 lines are a bit awkward
// TODO(1): the following 2 lines are a bit awkward
BaseGraph::add_nodes(that.number_of_nodes());
NodeManager<node_type>::add_active_nodes(that.number_of_nodes());

Expand Down Expand Up @@ -227,7 +227,7 @@ namespace libsemigroups {
template <typename P>
void Stephen<P>::run_impl() {
reset_start_time();
// TODO report_after_run (including report_why_we_stopped) and
// TODO(0): report_after_run (including report_why_we_stopped) and
// report_before_run
if (reporting_enabled()) {
detail::Ticker t([this]() { _word_graph.report_progress_from_thread(); });
Expand Down
10 changes: 5 additions & 5 deletions src/stephen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace libsemigroups {
int64_t diff = int64_t(_word_graph.number_of_nodes_active()
- stats.prev_active_nodes);
// TODO(v3) use fmtlib
// TODO(0) use fmtlib
static bool first_call = true;
if (first_call) {
first_call = false;
Expand Down Expand Up @@ -119,7 +119,7 @@ namespace libsemigroups {
}
// TODO port changes from here into tpp file
// TODO(0) port changes from here into tpp file
void Stephen::run_impl() {
auto start_time = std::chrono::high_resolution_clock::now();
// if (!initted()) {
Expand All @@ -146,7 +146,7 @@ namespace libsemigroups {
if (rit == it->cend()) {
++it;
if (it->empty()) {
// TODO move this logic into complete_path
// TODO(0) move this logic into complete_path
did_def = false;
c = current;
} else {
Expand Down Expand Up @@ -177,7 +177,7 @@ namespace libsemigroups {
if (rit == it->cend()) {
--it;
if (it->empty()) {
// TODO move this logic into complete_path
// TODO(0) move this logic into complete_path
continue;
} else {
c = _word_graph
Expand Down Expand Up @@ -230,7 +230,7 @@ namespace libsemigroups {
int64_t diff = int64_t(_word_graph.number_of_nodes_active()
- stats.prev_active_nodes);
// TODO(v3) use fmtlib
// TODO(0) use fmtlib
static bool first_call = true;
if (first_call) {
first_call = false;
Expand Down
4 changes: 2 additions & 2 deletions tests/test-stephen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1414,10 +1414,10 @@ namespace libsemigroups {
Stephen S(p);
S.set_word(0110_w).run();
REQUIRE(S.word_graph().number_of_nodes() == 8);
// TODO rename words_accepted -> class_of
// TODO(0): rename words_accepted -> class_of
REQUIRE((stephen::words_accepted(S) | rx::to_vector())
== std::vector<word_type>());
}

// TODO the examples from Stephen's paper/thesis?
// TODO(0): the examples from Stephen's paper/thesis?
} // namespace libsemigroups

0 comments on commit b975493

Please sign in to comment.