From 22e92742702b37dcebd23c0722814a55dcd40f97 Mon Sep 17 00:00:00 2001
From: Tomas Pecka <peckato1@fit.cvut.cz>
Date: Wed, 11 Jul 2018 14:07:46 +0200
Subject: [PATCH] algo: doc automaton::simplify

---
 .../simplify/EpsilonRemoverIncoming.h         | 46 ++++++++++++-
 .../simplify/EpsilonRemoverOutgoing.h         | 42 +++++++++++-
 alib2algo/src/automaton/simplify/Minimize.h   | 60 +++++++++++++++++
 .../automaton/simplify/MinimizeBrzozowski.h   | 35 ++++++++++
 alib2algo/src/automaton/simplify/Normalize.h  | 65 ++++++++++++++++---
 alib2algo/src/automaton/simplify/Rename.h     | 49 ++++++++++++++
 .../automaton/simplify/SingleInitialState.h   | 53 ++++++++++++++-
 .../SingleInitialStateEpsilonTransition.h     | 52 ++++++++++++++-
 alib2algo/src/automaton/simplify/Total.h      | 32 +++++++--
 alib2algo/src/automaton/simplify/Trim.h       | 27 +++++++-
 .../simplify/UnreachableStatesRemover.h       | 55 +++++++++++++++-
 .../automaton/simplify/UselessStatesRemover.h | 54 ++++++++++++++-
 12 files changed, 546 insertions(+), 24 deletions(-)

diff --git a/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h b/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h
index a7f3eb137c..ad84682d41 100644
--- a/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h
+++ b/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h
@@ -1,6 +1,22 @@
 /*
  * EpsilonRemoverIncoming.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: 24. 11. 2014
  *	  Author: Jan Travnicek
  */
@@ -19,17 +35,45 @@ namespace automaton {
 
 namespace simplify {
 
+/**
+ * Removes epsilon transitions from an automaton.
+ * This method is the one teached at BI-AAG course.
+ *
+ * @sa automaton::simplify::EpsilonRemoverOutgoing
+ */
 class EpsilonRemoverIncoming {
 public:
 	/**
-	 * Computes epsilon closure of a state in epsilon nonfree automaton
+	 * Removes epsilon transitions from an automaton.
+	 *
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam EpsilonType Type for epsilon symbol.
+	 * @tparam StateType Type for states.
+	 * @param fsm automaton to remove epsilon transitions from
+	 * @return an automaton equivalent to @p fsm but without epsilon transitions
 	 */
 	template < class SymbolType, class EpsilonType, class StateType >
 	static automaton::NFA < SymbolType, StateType > remove( const automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > & fsm );
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::MultiInitialStateNFA < SymbolType, StateType > remove( const automaton::MultiInitialStateNFA < SymbolType, StateType > & fsm );
+
+	/**
+	 * For nondeterministic finite automata, we remove nothing and return the @p fsm
+	 *
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::NFA < SymbolType, StateType > remove( const automaton::NFA < SymbolType, StateType > & fsm );
+
+	/**
+	 * For deterministic finite automata, we remove nothing and return the @p fsm
+	 *
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, StateType > remove( const automaton::DFA < SymbolType, StateType > & fsm );
 
diff --git a/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h b/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h
index 5fe44f2c1c..eaf6006268 100644
--- a/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h
+++ b/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h
@@ -1,6 +1,22 @@
 /*
  * EpsilonRemoverOutgoing.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: 16. 1. 2014
  *	  Author: Tomas Pecka
  */
@@ -21,17 +37,41 @@ namespace automaton {
 
 namespace simplify {
 
+/**
+ * Removes epsilon transitions from an automaton.
+ * This method returns multi-initial state automata (it is not the one teached at BI-AAG course).
+ *
+ * @sa automaton::simplify::EpsilonRemoverIncoming
+ */
 class EpsilonRemoverOutgoing {
 public:
 	/**
-	 * Computes epsilon closure of a state in epsilon nonfree automaton
+	 * Removes epsilon transitions from an automaton.
+	 *
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam EpsilonType Type for epsilon symbol.
+	 * @tparam StateType Type for states.
+	 * @param fsm automaton to remove epsilon transitions from
+	 * @return an automaton (with multiple initial states) equivalent to @p fsm but without epsilon transitions
 	 */
 	template < class StateType, class EpsilonType, class SymbolType >
 	static automaton::MultiInitialStateNFA < SymbolType, StateType > remove( const automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > & fsm );
+
+	/**
+	 * @overload
+	 */
 	template < class StateType, class SymbolType >
 	static automaton::MultiInitialStateNFA < SymbolType, StateType > remove( const automaton::MultiInitialStateNFA < SymbolType, StateType > & fsm );
+
+	/**
+	 * @overload
+	 */
 	template < class StateType, class SymbolType >
 	static automaton::NFA < SymbolType, StateType > remove( const automaton::NFA < SymbolType, StateType > & fsm );
+
+	/**
+	 * @overload
+	 */
 	template < class StateType, class SymbolType >
 	static automaton::DFA < SymbolType, StateType > remove( const automaton::DFA < SymbolType, StateType > & fsm );
 };
diff --git a/alib2algo/src/automaton/simplify/Minimize.h b/alib2algo/src/automaton/simplify/Minimize.h
index aaf184f943..98a7a7665e 100644
--- a/alib2algo/src/automaton/simplify/Minimize.h
+++ b/alib2algo/src/automaton/simplify/Minimize.h
@@ -1,6 +1,22 @@
 /*
  * Minimize.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Dec 9, 2013
  *	  Author: Jan Travnicek
  */
@@ -22,23 +38,67 @@ namespace automaton {
 
 namespace simplify {
 
+/**
+ * Minimization of automata.
+ *
+ * For finite automata, we implement Hopcroft's subset minimization.
+ * For finite tree automata, we implement ???.
+ *
+ * @sa automaton::simplify::MinimizeBrzozowski
+ */
 class Minimize {
 public:
+	/**
+	 * Minimizes deterministic finite autmaton.
+	 *
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 * @param dfa deterministic finite automaton to minimize.
+	 * @return Minimal deterministic finite automaton equivalent to @p dfa
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, StateType > minimize(const automaton::DFA < SymbolType, StateType >& dfa) {
 		size_t steps;
 		return minimize ( dfa, steps );
 	}
 
+	/**
+	 * Minimizes deterministic finite autmaton, also reports number of iterations it took.
+	 *
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 * @param dfa deterministic finite automaton to minimize.
+	 * @param[out] steps Number of steps in the subset minimization performed until finished
+	 * @return Minimal deterministic finite automaton equivalent to @p dfa
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, StateType > minimize(const automaton::DFA < SymbolType, StateType >& dfa, size_t & steps);
 
+	/**
+	 * Minimizes deterministic finite tree autmaton.
+	 *
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam RankType Type for rank (arity) in ranked alphabet.
+	 * @tparam StateType Type for states.
+	 * @param dfta deterministic finite tree automaton to minimize.
+	 * @return Minimal deterministic finite automaton equivalent to @p dfa
+	 */
 	template < class SymbolType, class RankType, class StateType >
 	static automaton::DFTA < SymbolType, RankType, StateType > minimize(const automaton::DFTA < SymbolType, RankType, StateType >& dfta) {
 		size_t steps;
 		return minimize ( dfta, steps );
 	}
 
+	/**
+	 * Minimizes deterministic finite tree autmaton, also reports number of iterations it took.
+	 *
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam RankType Type for rank (arity) in ranked alphabet.
+	 * @tparam StateType Type for states.
+	 * @param dfta deterministic finite tree automaton to minimize.
+	 * @param[out] steps Number of steps in the subset minimization performed until finished
+	 * @return Minimal deterministic finite automaton equivalent to @p dfa
+	 */
 	template < class SymbolType, class RankType, class StateType >
 	static automaton::DFTA < SymbolType, RankType, StateType > minimize(const automaton::DFTA < SymbolType, RankType, StateType >& dfta, size_t & steps);
 
diff --git a/alib2algo/src/automaton/simplify/MinimizeBrzozowski.h b/alib2algo/src/automaton/simplify/MinimizeBrzozowski.h
index f0ee098729..0c46eeb3c8 100644
--- a/alib2algo/src/automaton/simplify/MinimizeBrzozowski.h
+++ b/alib2algo/src/automaton/simplify/MinimizeBrzozowski.h
@@ -1,6 +1,22 @@
 /*
  * MinimizeBrzozowski.cpp
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: 18. 11. 2014
  *	  Author: Tomas Pecka
  */
@@ -19,10 +35,29 @@ namespace automaton {
 
 namespace simplify {
 
+/**
+ * Minimization of finite automata.
+ *
+ * For finite automata, we implement Brzozowski's method. This method works also for the minimization of NFA to minimal DFA.
+ *
+ * Implements: Brzozowski, J.A.: Canonical regular expressions and minimal state graphs for definite events (1962)
+ *
+ * @sa automaton::simplify::Minimize
+ */
 class MinimizeBrzozowski {
 public:
+	/**
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 * @param dfa finite automaton to minimize.
+	 * @return Minimal deterministic finite automaton equivalent to @p dfa
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, ext::set < ext::set < StateType > > > minimize(const automaton::DFA < SymbolType, StateType > & dfa);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, ext::set < ext::set < StateType > > > minimize(const automaton::NFA < SymbolType, StateType > & nfa);
 };
diff --git a/alib2algo/src/automaton/simplify/Normalize.h b/alib2algo/src/automaton/simplify/Normalize.h
index d5473d7901..1227a42157 100644
--- a/alib2algo/src/automaton/simplify/Normalize.h
+++ b/alib2algo/src/automaton/simplify/Normalize.h
@@ -1,6 +1,22 @@
 /*
  * Normalize.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Dec 9, 2013
  *	  Author: Jan Travnicek
  */
@@ -15,15 +31,46 @@ namespace automaton {
 
 namespace simplify {
 
+/**
+ * Normalization of an automaton.
+ * Basically, we rename the automaton's properties (states, pushdown symbols, ...) in such fashion, that the naming is same for isomorphic automata.
+ *
+ * Unlike Rename, we can normalize only deterministic automata.
+ *
+ * @sa automaton::simplify::Rename
+ */
 class Normalize {
 public:
 	/**
-	 * @param dfa automaton to normalize
+	 * Normalization of deterministic finite automata.
+	 * The process of normalization is a BFS traversal through the graph representing the automaton. The states are named by integers in the visited order.
+	 *
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 * @param dfa determinsitic finite automaton to normalize
+	 * @return @p dfa with state labels normalized
+	 *
+	 * @throws exception::CommonException if the passed dfa was not minimal connected dfa
 	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, unsigned > normalize(const automaton::DFA < SymbolType, StateType > & dfa);
+
+	/**
+	 * Normalization of deterministic pushdown automata.
+	 * The process of normalization of states is a BFS traversal through the graph representing the automaton. The states are named by integers in the visited order.
+	 * We normalize also the pushdown store symbols.
+	 *
+	 * @tparam InputSymbolType Type for input symbols.
+	 * @tparam EpsilonType Type for epsilon symbol.
+	 * @tparam PushdownStoreSymbolType Type for pushdown store symbols.
+	 * @tparam StateType Type for states.
+	 * @param dpda determinsitic pushdown automaton to normalize
+	 * @return @p dpda with state labels normalized
+	 *
+	 * @throws exception::CommonException if the passed dpda was not deterministic connected pda
+	 */
 	template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType >
-	static automaton::DPDA < InputSymbolType, EpsilonType, unsigned, unsigned > normalize(const automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & dfa);
+	static automaton::DPDA < InputSymbolType, EpsilonType, unsigned, unsigned > normalize(const automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & dpda);
 };
 
 template < class SymbolType, class StateType >
@@ -91,10 +138,10 @@ automaton::DPDA < InputSymbolType, EpsilonType, unsigned, unsigned > Normalize::
 		bool stateFinished = true;
 		// For each transition from state current
 		for ( const std::pair < const ext::tuple < StateType, ext::variant < EpsilonType, InputSymbolType >, ext::vector < PushdownStoreSymbolType > >, std::pair < StateType, ext::vector < PushdownStoreSymbolType > > > & iter : pda.getTransitionsFromState(current)) {
-			// look whether all poped symbols are already transformed
+			// look whether all pop symbols are already transformed
 			if(std::all_of(std::get<2>(iter.first).begin(), std::get<2>(iter.first).end(), [&](const PushdownStoreSymbolType& symbol) { return normalizationDataSymbol.find(symbol) != normalizationDataSymbol.end(); })) {
 				ext::vector < unsigned > transformedSymbols;
-				// if so compute vector of transformed poped symbol -- this can be compared to other vectors of transformed symbols and the order can by trusted
+				// if so compute vector of transformed poped symbol -- this can be compared to other vectors of transformed symbols and the order can be trusted
 				for(const PushdownStoreSymbolType& symbol : std::get<2> ( iter.first ) ) {
 					transformedSymbols.push_back(normalizationDataSymbol.find(symbol)->second);
 				}
@@ -105,21 +152,21 @@ automaton::DPDA < InputSymbolType, EpsilonType, unsigned, unsigned > Normalize::
 				stateFinished = false;
 			}
 		}
-		// if there was a single transition with undefined transformation for poped symbol process this state again later
+		// if there was a single transition with undefined transformation for pop symbol process this state again later
 		if(!stateFinished) {
 			processingData.push_back(std::move ( current ) );
 		}
-		// now transitions are trivialy sorted by input symbol and the already transformed symbols
+		// now transitions are trivially sorted by input symbol and the already transformed symbols
 
-		// for each pair state, pushed symbols in order given by input symbol and transformed poped symbols
+		// for each pair state, pushed symbols in order given by input symbol and transformed pop symbols
 		for(const auto& iter : transform) {
 			const auto& iters = iter.second;
-			// if the state is new asign a unique number to it and mark it for processing
+			// if the state is new assign a unique number to it and mark it for processing
 			if( normalizationDataState.find(iters.first) == normalizationDataState.end() ) {
 				normalizationDataState.insert(std::make_pair(iters.first, counterState++));
 				processingData.push_back(iters.first);
 			}
-			// if the symbols in order given by order of pushing are new asign a unique number to them
+			// if the symbols in order given by order of pushing are new assign a unique number to them
 			for(const PushdownStoreSymbolType & iter2 : iters.second) {
 				if( normalizationDataSymbol.find(iter2) == normalizationDataSymbol.end() ) {
 					normalizationDataSymbol.insert(std::make_pair(iter2, counterSymbol++));
diff --git a/alib2algo/src/automaton/simplify/Rename.h b/alib2algo/src/automaton/simplify/Rename.h
index f93086b4c5..2009ab4f7c 100644
--- a/alib2algo/src/automaton/simplify/Rename.h
+++ b/alib2algo/src/automaton/simplify/Rename.h
@@ -1,6 +1,22 @@
 /*
  * Rename.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Dec 9, 2013
  *      Author: Jan Travnicek
  */
@@ -25,23 +41,56 @@ namespace automaton {
 
 namespace simplify {
 
+/**
+ * Rename an automaton.
+ * Basically, we rename the automaton's properties (states, pushdown symbols, ...) to integer values in non-defined order.
+ *
+ * Unlike Normalize, we can rename also nondeterministic automata as the order is not important.
+ *
+ * @sa automaton::simplify::Normalize
+ */
 class Rename {
 public:
+	/**
+	 * Rename automaton's properties.
+	 *
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 * @param dfa finite automaton to normalize
+	 * @return @p dfa with renamed properties
+	 *
+	 * @throws exception::CommonException if the passed dfa was not minimal connected dfa
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, unsigned > rename ( const automaton::DFA < SymbolType, StateType > & dfa );
 
+	/**
+	 * @overload
+	 */
 	template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType >
 	static automaton::DPDA < InputSymbolType, EpsilonType, unsigned, unsigned > rename ( const automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & pda );
 
+	/**
+	 * @overload
+	 */
 	template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType >
 	static automaton::SinglePopDPDA < InputSymbolType, EpsilonType, unsigned, unsigned > rename ( const automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & pda );
 
+	/**
+	 * @overload
+	 */
 	template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
 	static automaton::InputDrivenDPDA < InputSymbolType, unsigned, unsigned > rename ( const automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & pda );
 
+	/**
+	 * @overload
+	 */
 	template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
 	static automaton::VisiblyPushdownDPDA < InputSymbolType, unsigned, unsigned > rename ( const automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & pda );
 
+	/**
+	 * @overload
+	 */
 	template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType >
 	static automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, unsigned, unsigned > rename ( const automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & pda );
 };
diff --git a/alib2algo/src/automaton/simplify/SingleInitialState.h b/alib2algo/src/automaton/simplify/SingleInitialState.h
index 715bd93039..6eea5391e5 100644
--- a/alib2algo/src/automaton/simplify/SingleInitialState.h
+++ b/alib2algo/src/automaton/simplify/SingleInitialState.h
@@ -1,6 +1,22 @@
 /*
  * SingleInitialState.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: 20. 9. 2014
  *	  Author: Tomas Pecka
  */
@@ -27,26 +43,57 @@ namespace automaton {
 namespace simplify {
 
 /**
- * Makes finite automaton's transition function convert.
- * Source: Melichar: Algorithm 2.22
+ * Algorithm for the conversion of multi-initial state finite automata to single-initial state finite automata.
+ * This algorithm is an implementation of Melichar: Jazyky a překlady 2.46.
+ *
+ * @sa automaton::simplify::SingleInitialStateEpsilonTransition
  */
 class SingleInitialState {
 public:
 	/**
-	 * Computes epsilon closure of a state in epsilon nonfree automaton
+	 * Converts multi-initial state automaton to a single-initial state automaton.
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 * @param automaton automaton to convert
+	 * @return an automaton equivalent to @p with only one initial state
 	 */
 	template < class SymbolType, class StateType >
 	static automaton::NFA < SymbolType, StateType > convert(const automaton::MultiInitialStateNFA < SymbolType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class EpsilonType, class StateType >
 	static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > convert(const automaton::MultiInitialStateEpsilonNFA < SymbolType, EpsilonType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, StateType > convert(const automaton::DFA < SymbolType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::NFA < SymbolType, StateType > convert(const automaton::NFA < SymbolType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 * @tparam EpsilonType Type for epsilon symbol.
+	 */
 	template < class SymbolType, class EpsilonType, class StateType >
 	static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > convert(const automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::ExtendedNFA < SymbolType, StateType > convert(const automaton::ExtendedNFA < SymbolType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::CompactNFA < SymbolType, StateType > convert(const automaton::CompactNFA < SymbolType, StateType > & automaton);
 };
diff --git a/alib2algo/src/automaton/simplify/SingleInitialStateEpsilonTransition.h b/alib2algo/src/automaton/simplify/SingleInitialStateEpsilonTransition.h
index 22e590b75f..eabda3151e 100644
--- a/alib2algo/src/automaton/simplify/SingleInitialStateEpsilonTransition.h
+++ b/alib2algo/src/automaton/simplify/SingleInitialStateEpsilonTransition.h
@@ -1,6 +1,22 @@
 /*
  * SingleInitialStateEpsilonTransition.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: 6. 6. 2018
  *	  Author: Jan Travnicek
  */
@@ -24,26 +40,56 @@ namespace automaton {
 namespace simplify {
 
 /**
- * Makes finite automaton's transition function convert.
- * Source: Melichar: Algorithm 2.22
+ * Algorithm for the conversion of multi-initial state finite automata to single-initial state finite automata using epsilon transitions.
+ *
+ * @sa automaton::simplify::SingleInitialState
  */
 class SingleInitialStateEpsilonTransition {
 public:
 	/**
-	 * Computes epsilon closure of a state in epsilon nonfree automaton
+	 * Converts multi-initial state automaton to a single-initial state automaton with the use of epsilon transitions.
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 * @tparam EpsilonType Type for epsilon symbol.
+	 * @param automaton automaton to convert
+	 * @return an automaton equivalent to @p with only one initial state
 	 */
 	template < class SymbolType, class StateType >
 	static automaton::EpsilonNFA < SymbolType, DefaultEpsilonType, StateType > convert(const automaton::MultiInitialStateNFA < SymbolType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class EpsilonType, class StateType >
 	static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > convert(const automaton::MultiInitialStateEpsilonNFA < SymbolType, EpsilonType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, StateType > convert(const automaton::DFA < SymbolType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::NFA < SymbolType, StateType > convert(const automaton::NFA < SymbolType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class EpsilonType, class StateType >
 	static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > convert(const automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::ExtendedNFA < SymbolType, StateType > convert(const automaton::ExtendedNFA < SymbolType, StateType > & automaton);
+
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::CompactNFA < SymbolType, StateType > convert(const automaton::CompactNFA < SymbolType, StateType > & automaton);
 };
diff --git a/alib2algo/src/automaton/simplify/Total.h b/alib2algo/src/automaton/simplify/Total.h
index 819f89621e..33491bd7ea 100644
--- a/alib2algo/src/automaton/simplify/Total.h
+++ b/alib2algo/src/automaton/simplify/Total.h
@@ -1,6 +1,22 @@
 /*
  * Total.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: 20. 9. 2014
  *	  Author: Tomas Pecka
  */
@@ -20,19 +36,27 @@ namespace automaton {
 namespace simplify {
 
 /**
- * Makes finite automaton's transition function total.
- * Source: Melichar: Algorithm 2.22
+ * Algorithm that makes finite automaton's transition function total (every state has a transition for every symbol).
+ * Implementation of Melichar: Jazyky a překlady, 2.22.
  */
 class Total {
 public:
 	/**
-	 * Computes epsilon closure of a state in epsilon nonfree automaton
+	 * Makes a finite automaton's transition function total.
+	 *
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 * @param automaton automaton to alter
+	 * @return an automaton equivalent to @p automaton with total transition function
 	 */
 	template < class SymbolType, class StateType >
 	static automaton::NFA < SymbolType, StateType > total(const automaton::NFA < SymbolType, StateType > & automaton);
 
+	/**
+	 * @overload
+	 */
 	template < class SymbolType, class StateType >
-	static automaton::DFA < SymbolType, StateType > total(const automaton::DFA < SymbolType, StateType >& automaton);
+	static automaton::DFA < SymbolType, StateType > total(const automaton::DFA < SymbolType, StateType > & automaton);
 };
 
 template < class SymbolType, class StateType >
diff --git a/alib2algo/src/automaton/simplify/Trim.h b/alib2algo/src/automaton/simplify/Trim.h
index 8c042a97c4..3f0da70bd8 100644
--- a/alib2algo/src/automaton/simplify/Trim.h
+++ b/alib2algo/src/automaton/simplify/Trim.h
@@ -1,6 +1,22 @@
 /*
  * Trim.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: 23. 3. 2014
  *	  Author: Tomas Pecka
  */
@@ -15,10 +31,19 @@ namespace automaton {
 
 namespace simplify {
 
+/**
+ * Algorithm for the removal of dead states from a finite automaton.
+ * Firstly, it calls the useless states removal algorithm, then unreachable states removal algorithm.
+ *
+ * @sa automaton::simplify::UselessStatesRemover
+ * @sa automaton::simplify::UnreachableStatesRemover
+ */
 class Trim {
 public:
 	/**
-	 * Removes dead states from FSM. Melichar 2.29
+	 * @tparam T type of a finite automaton
+	 * @param fsm automaton to trim
+	 * @return T trimmed @p autoamton
 	 */
 	template<class T>
 	static T trim( const T & fsm );
diff --git a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h
index 5a9bfc0e4e..5b55af5854 100644
--- a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h
+++ b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h
@@ -1,6 +1,22 @@
 /*
  * UnreachableStatesRemover.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: 23. 3. 2014
  *	  Author: Tomas Pecka
  */
@@ -22,17 +38,54 @@ namespace automaton {
 
 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.
+ *
+ * @details
+ * For a finite automaton, we implement Melichar: Jazyky a překlady, 2.29.
+ * For a deterministic finite tree automaton, we implement ???
+ *
+ * @sa automaton::simplify::Trim
+ * @sa automaton::simplify::UselessStatesRemover
+ */
 class UnreachableStatesRemover {
 public:
 	/**
-	 * Removes dead states from FSM. Melichar 2.29
+	 * Removes unreachable states from an automaton.
+	 * @tparam T type of a finite automaton
+	 * @param automaton automaton to trim
+	 * @return @p automaton without unreachable states
 	 */
 	template < class T >
 	static T remove( const T & automaton );
+
+	/**
+	 * @overload
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, StateType > remove( const automaton::DFA < SymbolType, StateType > & fsm );
+
+	/**
+	 * @overload
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::MultiInitialStateNFA < SymbolType, StateType > remove( const automaton::MultiInitialStateNFA < SymbolType, StateType > & fsm );
+
+	/**
+	 * Removes unreachable states from a deterministic finite tree automaton.
+	 *
+	 * @overload
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam RankType Type for rank (arity) in ranked alphabet.
+	 * @tparam StateType Type for states.
+	 * @param dfta automaton to trim
+	 * @return @p autoamton without unreachable states
+	 */
 	template < class SymbolType, class RankType, class StateType >
 	static automaton::DFTA < SymbolType, RankType, StateType > remove( const automaton::DFTA < SymbolType, RankType, StateType > & dfta );
 };
diff --git a/alib2algo/src/automaton/simplify/UselessStatesRemover.h b/alib2algo/src/automaton/simplify/UselessStatesRemover.h
index 175ed5b0f8..96d2130263 100644
--- a/alib2algo/src/automaton/simplify/UselessStatesRemover.h
+++ b/alib2algo/src/automaton/simplify/UselessStatesRemover.h
@@ -1,6 +1,22 @@
 /*
  * UselessStatesRemover.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: 23. 3. 2014
  *	  Author: Tomas Pecka
  */
@@ -22,17 +38,53 @@ namespace automaton {
 
 namespace simplify {
 
+/**
+ * Algorithm for the removal of useless states from a finite automaton and a deterministic finite tree automaton.
+ * A state @p q is called useless if there is no path from @p q to any final state.
+ *
+ * For a finite automaton, we implement Melichar: Jazyky a překlady, 2.32.
+ * For a deterministic finite tree automaton, we implement ???
+ *
+ * @sa automaton::simplify::Trim
+ * @sa automaton::simplify::UnreachableStatesRemover
+ */
 class UselessStatesRemover {
 public:
 	/**
-	 * Removes dead states from FSM. Melichar 2.29
+	 * Removes useless states from an automaton.
+	 * @tparam T type of a finite automaton
+	 * @param automaton automaton to trim
+	 * @return @p automaton without useless states
 	 */
 	template < class T >
 	static T remove( const T & automaton );
+
+	/**
+	 * @overload
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::DFA < SymbolType, StateType > remove( const automaton::DFA < SymbolType, StateType > & fsm );
+
+	/**
+	 * @overload
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam StateType Type for states.
+	 */
 	template < class SymbolType, class StateType >
 	static automaton::MultiInitialStateNFA < SymbolType, StateType > remove( const automaton::MultiInitialStateNFA < SymbolType, StateType > & fsm );
+
+	/**
+	 * Removes unreachable states from a deterministic finite tree automaton.
+	 *
+	 * @overload
+	 * @tparam SymbolType Type for input symbols.
+	 * @tparam RankType Type for rank (arity) in ranked alphabet.
+	 * @tparam StateType Type for states.
+	 * @param dfta automaton to trim
+	 * @return @p autoamton without unreachable states
+	 */
 	template < class SymbolType, class RankType, class StateType >
 	static automaton::DFTA < SymbolType, RankType, StateType > remove( const automaton::DFTA < SymbolType, RankType, StateType > & dfta );
 };
-- 
GitLab