From 397820c64f1c657b468ecc609ed2806c83bc3c8c Mon Sep 17 00:00:00 2001
From: Ondrej Storc <storcond@fit.cvut.cz>
Date: Wed, 22 Jan 2025 15:03:16 +0100
Subject: [PATCH 1/2] algo: Fix naming of algorithms in UI

Changing 'inaccessible' to 'unreachable' to be consistent with BI-AAG
---
 alib2algo/src/automaton/simplify/Trim.cpp | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/alib2algo/src/automaton/simplify/Trim.cpp b/alib2algo/src/automaton/simplify/Trim.cpp
index f418542306..084ed6086b 100644
--- a/alib2algo/src/automaton/simplify/Trim.cpp
+++ b/alib2algo/src/automaton/simplify/Trim.cpp
@@ -12,52 +12,52 @@
 
 namespace {
 
-auto TrimDFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::DFA<>, const automaton::DFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
+auto TrimDFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::DFA<>, const automaton::DFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
 \n\
 @param fsm finite automaton or finite tree automaton to trim\n\
 @return the trimmed automaton equivalent to @p fsm");
 
-auto TrimNFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::NFA<>, const automaton::NFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
+auto TrimNFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::NFA<>, const automaton::NFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
 \n\
 @param fsm finite automaton or finite tree automaton to trim\n\
 @return the trimmed automaton equivalent to @p fsm");
 
-auto TrimMultiInitialStateNFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::MultiInitialStateNFA<>, const automaton::MultiInitialStateNFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
+auto TrimMultiInitialStateNFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::MultiInitialStateNFA<>, const automaton::MultiInitialStateNFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
 \n\
 @param fsm finite automaton or finite tree automaton to trim\n\
 @return the trimmed automaton equivalent to @p fsm");
 
-auto TrimEpsilonNFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::EpsilonNFA<>, const automaton::EpsilonNFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
+auto TrimEpsilonNFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::EpsilonNFA<>, const automaton::EpsilonNFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
 \n\
 @param fsm finite automaton or finite tree automaton to trim\n\
 @return the trimmed automaton equivalent to @p fsm");
 
-auto TrimCompactNFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::CompactNFA<>, const automaton::CompactNFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
+auto TrimCompactNFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::CompactNFA<>, const automaton::CompactNFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
 \n\
 @param fsm finite automaton or finite tree automaton to trim\n\
 @return the trimmed automaton equivalent to @p fsm");
 
-auto TrimExtendedNFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::ExtendedNFA<>, const automaton::ExtendedNFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
+auto TrimExtendedNFA = registration::AbstractRegister<automaton::simplify::Trim, automaton::ExtendedNFA<>, const automaton::ExtendedNFA<>&>(automaton::simplify::Trim::trim, "fsm").setDocumentation("Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
 \n\
 @param fsm finite automaton or finite tree automaton to trim\n\
 @return the trimmed automaton equivalent to @p fsm");
 
-auto TrimDFTA = registration::AbstractRegister<automaton::simplify::Trim, automaton::DFTA<>, const automaton::DFTA<>&>(automaton::simplify::Trim::trim, "fta").setDocumentation("Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
+auto TrimDFTA = registration::AbstractRegister<automaton::simplify::Trim, automaton::DFTA<>, const automaton::DFTA<>&>(automaton::simplify::Trim::trim, "fta").setDocumentation("Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
 \n\
 @param fta finite tree automaton or finite tree automaton to trim\n\
 @return the trimmed automaton equivalent to @p fta");
 
-auto TrimNFTA = registration::AbstractRegister<automaton::simplify::Trim, automaton::NFTA<>, const automaton::NFTA<>&>(automaton::simplify::Trim::trim, "fta").setDocumentation("Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
+auto TrimNFTA = registration::AbstractRegister<automaton::simplify::Trim, automaton::NFTA<>, const automaton::NFTA<>&>(automaton::simplify::Trim::trim, "fta").setDocumentation("Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
 \n\
 @param fta finite automaton or finite tree automaton to trim\n\
 @return the trimmed automaton equivalent to @p fta");
 
-auto TrimAFDZA = registration::AbstractRegister<automaton::simplify::Trim, automaton::ArcFactoredDeterministicZAutomaton<>, const automaton::ArcFactoredDeterministicZAutomaton<>&>(automaton::simplify::Trim::trim, "afdza").setDocumentation("Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
+auto TrimAFDZA = registration::AbstractRegister<automaton::simplify::Trim, automaton::ArcFactoredDeterministicZAutomaton<>, const automaton::ArcFactoredDeterministicZAutomaton<>&>(automaton::simplify::Trim::trim, "afdza").setDocumentation("Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
 \n\
 @param afdza deterministic arc factored z-automaton\n\
 @return the trimmed automaton equivalent to @p afdza");
 
-auto TrimAFNZA = registration::AbstractRegister<automaton::simplify::Trim, automaton::ArcFactoredNondeterministicZAutomaton<>, const automaton::ArcFactoredNondeterministicZAutomaton<>&>(automaton::simplify::Trim::trim, "afdza").setDocumentation("Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
+auto TrimAFNZA = registration::AbstractRegister<automaton::simplify::Trim, automaton::ArcFactoredNondeterministicZAutomaton<>, const automaton::ArcFactoredNondeterministicZAutomaton<>&>(automaton::simplify::Trim::trim, "afdza").setDocumentation("Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.\n\
 \n\
 @param afdza deterministic arc factored z-automaton\n\
 @return the trimmed automaton equivalent to @p afdza");
-- 
GitLab


From 43b3538f5f5430f7fa989f4549ce0627dcb230d7 Mon Sep 17 00:00:00 2001
From: Ondrej Storc <storcond@fit.cvut.cz>
Date: Wed, 22 Jan 2025 15:13:57 +0100
Subject: [PATCH 2/2] algo: Fix naming of algorithms in code

---
 .../generate/RandomAutomatonFactory.cpp       |  4 ++--
 .../generate/RandomAutomatonFactory.h         | 20 +++++++++----------
 .../generate/RandomTreeAutomatonFactory.cpp   |  4 ++--
 .../generate/RandomTreeAutomatonFactory.h     | 20 +++++++++----------
 alib2algo/src/automaton/simplify/Trim.h       |  2 +-
 .../simplify/UnreachableStatesRemover.h       |  2 +-
 .../simplify/UnreachableSymbolsRemover.h      |  2 +-
 .../matching/HammingMatchingAutomaton.h       |  2 +-
 .../src/automaton/RandomAutomatonFactory2.cpp |  4 ++--
 9 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/alib2algo/src/automaton/generate/RandomAutomatonFactory.cpp b/alib2algo/src/automaton/generate/RandomAutomatonFactory.cpp
index add4b87c57..281b453118 100644
--- a/alib2algo/src/automaton/generate/RandomAutomatonFactory.cpp
+++ b/alib2algo/src/automaton/generate/RandomAutomatonFactory.cpp
@@ -3,7 +3,7 @@
 
 namespace automaton::generate {
 
-unsigned RandomAutomatonFactory::ithAccessibleState(const ext::deque<bool>& VStates, size_t i)
+unsigned RandomAutomatonFactory::ithReachableState(const ext::deque<bool>& VStates, size_t i)
 {
     i++;
     for (size_t j = 0; j < VStates.size(); j++) {
@@ -16,7 +16,7 @@ unsigned RandomAutomatonFactory::ithAccessibleState(const ext::deque<bool>& VSta
     throw std::logic_error("Not enough states in deque of visited states");
 }
 
-unsigned RandomAutomatonFactory::ithInaccessibleState(const ext::deque<bool>& VStates, size_t i)
+unsigned RandomAutomatonFactory::ithUnreachableState(const ext::deque<bool>& VStates, size_t i)
 {
     i++;
     for (size_t j = 0; j < VStates.size(); j++) {
diff --git a/alib2algo/src/automaton/generate/RandomAutomatonFactory.h b/alib2algo/src/automaton/generate/RandomAutomatonFactory.h
index 4e9dbbb6e7..9498c7d26d 100644
--- a/alib2algo/src/automaton/generate/RandomAutomatonFactory.h
+++ b/alib2algo/src/automaton/generate/RandomAutomatonFactory.h
@@ -56,24 +56,24 @@ public:
 
 private:
     /**
-     * Selects ith accessible state form \p VStates.
+     * Selects ith reachable state form \p VStates.
      *
      * \param VStates the states to select from
-     * \param i the specification which accessble state to select
+     * \param i the specification which reachable state to select
      *
-     * \return ith accessible state based on VStates
+     * \return ith reachable state based on VStates
      */
-    static unsigned ithAccessibleState(const ext::deque<bool>& VStates, size_t i);
+    static unsigned ithReachableState(const ext::deque<bool>& VStates, size_t i);
 
     /**
-     * Selects ith inaccessible state form \p VStates.
+     * Selects ith unreachable state form \p VStates.
      *
      * \param VStates the states to select from
-     * \param i the specification which inaccessble state to select
+     * \param i the specification which unreachable state to select
      *
-     * \return ith inaccessible state based on VStates
+     * \return ith unreachable state based on VStates
      */
-    static unsigned ithInaccessibleState(const ext::deque<bool>& VStates, size_t i);
+    static unsigned ithUnreachableState(const ext::deque<bool>& VStates, size_t i);
 
     /**
      * Leslie's connected NFA algorithm
@@ -132,8 +132,8 @@ automaton::NFA<SymbolType, unsigned> RandomAutomatonFactory::LeslieConnectedNFA(
     VStates[0] = true;
 
     while (unvisited != 0) {
-        size_t a = ithAccessibleState(VStates, std::uniform_int_distribution<size_t>(0, n - unvisited - 1)(ext::random_devices::semirandom)); // select y-th accessible state
-        size_t b = ithInaccessibleState(VStates, std::uniform_int_distribution<size_t>(0, unvisited - 1)(ext::random_devices::semirandom)); // select z-th inaccessible state
+        size_t a = ithReachableState(VStates, std::uniform_int_distribution<size_t>(0, n - unvisited - 1)(ext::random_devices::semirandom)); // select y-th Reachable state
+        size_t b = ithUnreachableState(VStates, std::uniform_int_distribution<size_t>(0, unvisited - 1)(ext::random_devices::semirandom)); // select z-th Unreachable state
 
         size_t c = std::uniform_int_distribution<size_t>(0, alphabet.size() - 1)(ext::random_devices::semirandom);
         automaton.addTransition(Q[a], alphabet[c], Q[b]);
diff --git a/alib2algo/src/automaton/generate/RandomTreeAutomatonFactory.cpp b/alib2algo/src/automaton/generate/RandomTreeAutomatonFactory.cpp
index 3e1e145708..b971dd755b 100644
--- a/alib2algo/src/automaton/generate/RandomTreeAutomatonFactory.cpp
+++ b/alib2algo/src/automaton/generate/RandomTreeAutomatonFactory.cpp
@@ -3,7 +3,7 @@
 
 namespace automaton::generate {
 
-unsigned RandomTreeAutomatonFactory::ithAccessibleState(const ext::deque<bool>& VStates, size_t i)
+unsigned RandomTreeAutomatonFactory::ithReachableState(const ext::deque<bool>& VStates, size_t i)
 {
     i++;
     for (size_t j = 0; j < VStates.size(); j++) {
@@ -16,7 +16,7 @@ unsigned RandomTreeAutomatonFactory::ithAccessibleState(const ext::deque<bool>&
     throw std::logic_error("Not enough states in deque of visited states");
 }
 
-unsigned RandomTreeAutomatonFactory::ithInaccessibleState(const ext::deque<bool>& VStates, size_t i)
+unsigned RandomTreeAutomatonFactory::ithUnreachableState(const ext::deque<bool>& VStates, size_t i)
 {
     i++;
     for (size_t j = 0; j < VStates.size(); j++) {
diff --git a/alib2algo/src/automaton/generate/RandomTreeAutomatonFactory.h b/alib2algo/src/automaton/generate/RandomTreeAutomatonFactory.h
index 49eae15b44..54a974cae4 100644
--- a/alib2algo/src/automaton/generate/RandomTreeAutomatonFactory.h
+++ b/alib2algo/src/automaton/generate/RandomTreeAutomatonFactory.h
@@ -56,24 +56,24 @@ public:
 
 private:
     /**
-     * Selects ith accessible state form \p VStates.
+     * Selects ith reachable state form \p VStates.
      *
      * \param VStates the states to select from
-     * \param i the specification which accessble state to select
+     * \param i the specification which reachable state to select
      *
-     * \return ith accessible state based on VStates
+     * \return ith reachable state based on VStates
      */
-    static unsigned ithAccessibleState(const ext::deque<bool>& VStates, size_t i);
+    static unsigned ithReachableState(const ext::deque<bool>& VStates, size_t i);
 
     /**
-     * Selects ith inaccessible state form \p VStates.
+     * Selects ith unreachable state form \p VStates.
      *
      * \param VStates the states to select from
-     * \param i the specification which inaccessble state to select
+     * \param i the specification which unreachable state to select
      *
-     * \return ith inaccessible state based on VStates
+     * \return ith unreachable state based on VStates
      */
-    static unsigned ithInaccessibleState(const ext::deque<bool>& VStates, size_t i);
+    static unsigned ithUnreachableState(const ext::deque<bool>& VStates, size_t i);
 
     /**
      * Leslie's connected NFTA algorithm
@@ -140,11 +140,11 @@ automaton::NFTA<SymbolType, unsigned> RandomTreeAutomatonFactory::LeslieConnecte
         size_t c = std::uniform_int_distribution<size_t>(0, alphabet.size() - 1)(ext::random_devices::semirandom);
         ext::vector<unsigned> from;
         while (from.size() < alphabet[c].getRank()) {
-            size_t a = ithAccessibleState(VStates, std::uniform_int_distribution<size_t>(0, n - unvisited - 1)(ext::random_devices::semirandom)); // select y-th accessible state
+            size_t a = ithReachableState(VStates, std::uniform_int_distribution<size_t>(0, n - unvisited - 1)(ext::random_devices::semirandom)); // select y-th reachable state
             from.push_back(Q[a]);
         }
 
-        size_t b = ithInaccessibleState(VStates, std::uniform_int_distribution<size_t>(0, unvisited - 1)(ext::random_devices::semirandom)); // select z-th inaccessible state
+        size_t b = ithReachableState(VStates, std::uniform_int_distribution<size_t>(0, unvisited - 1)(ext::random_devices::semirandom)); // select z-th reachable state
 
         automaton.addTransition(alphabet[c], std::move(from), Q[b]);
 
diff --git a/alib2algo/src/automaton/simplify/Trim.h b/alib2algo/src/automaton/simplify/Trim.h
index c0452aefd8..17126709e2 100644
--- a/alib2algo/src/automaton/simplify/Trim.h
+++ b/alib2algo/src/automaton/simplify/Trim.h
@@ -35,7 +35,7 @@ namespace simplify {
 class Trim {
 public:
     /**
-     * Removes inaccessible and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.
+     * Removes unreachable and useless states from the given automaton. Uses first the @sa UselessStatesRemover and next @sa UnreachableStatesRemover in the process.
      *
      * @tparam T type of a finite automaton
      *
diff --git a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h
index 60dd718268..d2d74363c7 100644
--- a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h
+++ b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h
@@ -36,7 +36,7 @@ namespace simplify {
 
 /**
  * Algorithm for the removal of unreachable states from a finite automaton and a deterministic finite tree automaton.
- * Unreachable state is a state that is not accessible from the initial state of the automaton by any string.
+ * Unreachable state is a state that is not reachable from the initial state of the automaton by any string.
  *
  * @details
  * For a finite automaton, we implement Melichar: Jazyky a překlady, 2.29.
diff --git a/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h b/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h
index 476e832772..529de7a65a 100644
--- a/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h
+++ b/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h
@@ -25,7 +25,7 @@ namespace simplify {
 
 /**
  * Algorithm for the removal of unreachable symbols from a context free grammar.
- * Unreachable symbols is a symbol that is not accessible from the initial symbol of the automaton by any sequence of derivations.
+ * Unreachable symbols is a symbol that is not reachable from the initial symbol of the automaton by any sequence of derivations.
  *
  * @sa grammar::simplify::Trim
  * @sa grammar::properties::ReachableSymbols
diff --git a/alib2algo/src/stringology/matching/HammingMatchingAutomaton.h b/alib2algo/src/stringology/matching/HammingMatchingAutomaton.h
index b5997d8ed3..d786c3f63d 100644
--- a/alib2algo/src/stringology/matching/HammingMatchingAutomaton.h
+++ b/alib2algo/src/stringology/matching/HammingMatchingAutomaton.h
@@ -73,7 +73,7 @@ automaton::NFA<SymbolType, ext::pair<unsigned int, unsigned int>> HammingMatchin
         }
     }
 
-    // remove all inaccessible states from state
+    // remove all unreachable states from state
     return result;
 }
 
diff --git a/alib2algo_experimental/src/automaton/RandomAutomatonFactory2.cpp b/alib2algo_experimental/src/automaton/RandomAutomatonFactory2.cpp
index b9d914fe55..d1329b905a 100644
--- a/alib2algo_experimental/src/automaton/RandomAutomatonFactory2.cpp
+++ b/alib2algo_experimental/src/automaton/RandomAutomatonFactory2.cpp
@@ -5,7 +5,7 @@ namespace automaton::generate {
 
 size_t RandomAutomatonFactory2::randomSourceState(size_t statesMinimal, size_t visited, size_t depleted, const ext::deque<bool>& VStates, const ext::deque<bool>& DStates)
 {
-    size_t y = ext::random_devices::semirandom() % (visited - depleted) + 1; // select y-th accessible state
+    size_t y = ext::random_devices::semirandom() % (visited - depleted) + 1; // select y-th reachable state
 
     for (size_t i = 0, cnt = 0; i < statesMinimal; i++) {
         if (VStates[i] && !DStates[i])
@@ -20,7 +20,7 @@ size_t RandomAutomatonFactory2::randomSourceState(size_t statesMinimal, size_t v
 
 size_t RandomAutomatonFactory2::randomTargetState(size_t statesMinimal, size_t visited, const ext::deque<bool>& VStates)
 {
-    size_t z = ext::random_devices::semirandom() % (statesMinimal - visited) + 1; // select z-th inaccessible state
+    size_t z = ext::random_devices::semirandom() % (statesMinimal - visited) + 1; // select z-th unreachable state
 
     for (size_t i = 0, cnt = 0; i < statesMinimal; i++) {
         if (!VStates[i])
-- 
GitLab