From c3e6fb6be4fa1ee23a428dd0972d1112a08bdea9 Mon Sep 17 00:00:00 2001 From: Tomas Pecka <peckato1@fit.cvut.cz> Date: Tue, 10 Jul 2018 13:41:35 +0200 Subject: [PATCH] algo: document automaton::transform --- .../transform/AutomataConcatenation.h | 33 +++++++++++++++- .../AutomataConcatenationEpsilonTransition.h | 38 ++++++++++++++++++- .../AutomataIntersectionCartesianProduct.h | 34 ++++++++++++++++- .../transform/AutomataUnionCartesianProduct.h | 34 ++++++++++++++++- .../AutomataUnionEpsilonTransition.h | 38 ++++++++++++++++++- .../automaton/transform/AutomatonIteration.h | 32 +++++++++++++++- .../AutomatonIterationEpsilonTransition.h | 30 ++++++++++++++- .../src/automaton/transform/Compaction.h | 34 ++++++++++++++++- .../src/automaton/transform/PDAToRHPDA.h | 36 ++++++++++++++++++ .../src/automaton/transform/RHPDAToPDA.h | 36 ++++++++++++++++++ alib2algo/src/automaton/transform/Reverse.h | 35 +++++++++++++++++ 11 files changed, 365 insertions(+), 15 deletions(-) diff --git a/alib2algo/src/automaton/transform/AutomataConcatenation.h b/alib2algo/src/automaton/transform/AutomataConcatenation.h index 94ba4ac7d1..93d959713b 100644 --- a/alib2algo/src/automaton/transform/AutomataConcatenation.h +++ b/alib2algo/src/automaton/transform/AutomataConcatenation.h @@ -1,6 +1,22 @@ /* * AutomataConcatenation.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. 11. 2014 * Author: Tomas Pecka */ @@ -15,13 +31,26 @@ namespace automaton { namespace transform { /** - * Concatenates two automata. - * - For finite automata A1, A2, we create automaton L accepting L(A1).L(A2) (Melichar, 2.78) + * Concatenation of two finite automata. + * For finite automata A1, A2, we create a finite automaton A such that L(A) = L(A1).L(A2). + * This method utilizes epsilon transitions in finite automata (Melichar: Jazyky a překlady, 2.82). */ class AutomataConcatenation { public: + /** + * Concatenates two finite automata without using epsilon transitions. + * @tparam SymbolType Type for input symbols. + * @tparam StateType Type for states. + * @param first First automaton (A1) + * @param second Second automaton (A2) + * @return nondeterministic FA representing the concatenation of two automata + */ template < class SymbolType, class StateType > static automaton::NFA < SymbolType, StateType > concatenation(const automaton::DFA < SymbolType, StateType > & first, const automaton::DFA < SymbolType, StateType > & second); + + /** + * @overload + */ template < class SymbolType, class StateType > static automaton::NFA < SymbolType, StateType > concatenation(const automaton::NFA < SymbolType, StateType > & first, const automaton::NFA < SymbolType, StateType > & second); }; diff --git a/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h b/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h index 021d08c654..bb8e7daef8 100644 --- a/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h +++ b/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h @@ -1,6 +1,22 @@ /* * AutomataConcatenationEpsilonTransition.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. 11. 2014 * Author: Tomas Pecka */ @@ -15,15 +31,33 @@ namespace automaton { namespace transform { /** - * Concatenates two automata. - * - For finite automata A1, A2, we create automaton L accepting L(A1).L(A2) + * Concatenation of two finite automata. + * For finite automata A1, A2, we create a finite automaton A such that L(A) = L(A1).L(A2). + * This method utilizes epsilon transitions in finite automata (Melichar: Jazyky a překlady, 2.80). */ class AutomataConcatenationEpsilonTransition { public: + /** + * Concatenates two automata using epsilon transitions. + * @tparam SymbolType Type for input symbols. + * @tparam EpsilonType Type for epsilon symbol. Defaults to DefaultEpsilonType. + * @tparam StateType Type for states. + * @param first First automaton (A1) + * @param second Second automaton (A2) + * @return nondeterministic FA with epsilon transitions representing the concatenation of two automata + */ template < class SymbolType, class EpsilonType = DefaultEpsilonType, class StateType > static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > concatenation(const automaton::DFA < SymbolType, StateType > & first, const automaton::DFA < SymbolType, StateType > & second); + + /** + * @overload + */ template < class SymbolType, class EpsilonType = DefaultEpsilonType, class StateType > static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > concatenation(const automaton::NFA < SymbolType, StateType > & first, const automaton::NFA < SymbolType, StateType > & second); + + /** + * @overload + */ template < class SymbolType, class EpsilonType, class StateType > static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > concatenation(const automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > & first, const automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > & second); }; diff --git a/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.h b/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.h index cfb284245c..9265e2e5bd 100644 --- a/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.h +++ b/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.h @@ -1,6 +1,22 @@ /* * AutomataIntersectionCartesianProduct.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. 11. 2014 * Author: Tomas Pecka */ @@ -15,13 +31,27 @@ namespace automaton { namespace transform { /** - * Intersection of two automata. - * - For finite automata A1, A2, we create automaton L accepting L(A1) \cap L(A2) (Melichar, 2.75) + * Intersection of two finite automata. + * For finite automata A1, A2, we create a finite automaton A such that L(A) = L(A1) \cap L(A2). + * This method utilizes epsilon transitions in finite automata (Melichar: Jazyky a překlady, 2.75). */ class AutomataIntersectionCartesianProduct { public: + /** + * Intersects two finite automata. + * @tparam SymbolType Type for input symbols. + * @tparam StateType1 Type for states in the first automaton. + * @tparam StateType2 Type for states in the second automaton. + * @param first First automaton (A1) + * @param second Second automaton (A2) + * @return (non)deterministic FA representing the intersection of two automata + */ template < class SymbolType, class StateType1, class StateType2 > static automaton::NFA < SymbolType, ext::pair < StateType1, StateType2 > > intersection(const automaton::NFA < SymbolType, StateType1 > & first, const automaton::NFA < SymbolType, StateType2 > & second); + + /** + * @overload + */ template < class SymbolType, class StateType1, class StateType2 > static automaton::DFA < SymbolType, ext::pair < StateType1, StateType2 > > intersection(const automaton::DFA < SymbolType, StateType1 > & first, const automaton::DFA < SymbolType, StateType2 > & second); }; diff --git a/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.h b/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.h index 58c3748c2f..6adbe5936f 100644 --- a/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.h +++ b/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.h @@ -1,6 +1,22 @@ /* * AutomataUnionCartesianProduct.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. 11. 2014 * Author: Tomas Pecka */ @@ -15,13 +31,27 @@ namespace automaton { namespace transform { /** - * Union two automata. - * - For finite automata A1, A2, we create automaton L accepting L(A1) \cup L(A2) (Melichar, 2.71) + * Union of two finite automata. + * For finite automata A1, A2, we create a finite automaton A such that L(A) = L(A1) \cup L(A2). + * This method utilizes epsilon transitions in finite automata (Melichar: Jazyky a překlady, 2.71). */ class AutomataUnionCartesianProduct { public: + /** + * Union of two automata. + * @tparam SymbolType Type for input symbols. + * @tparam StateType1 Type for states in the first automaton. + * @tparam StateType2 Type for states in the second automaton. + * @param first First automaton (A1) + * @param second Second automaton (A2) + * @return (non)deterministic FA representing the union of two automata + */ template < class SymbolType, class StateType1, class StateType2 > static automaton::NFA < SymbolType, ext::pair < StateType1, StateType2 > > unification(const automaton::NFA < SymbolType, StateType1 > & first, const automaton::NFA < SymbolType, StateType2 > & second); + + /** + * @overload + */ template < class SymbolType, class StateType1, class StateType2 > static automaton::DFA < SymbolType, ext::pair < StateType1, StateType2 > > unification(const automaton::DFA < SymbolType, StateType1 > & first, const automaton::DFA < SymbolType, StateType2 > & second); }; diff --git a/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.h b/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.h index df6430f31b..0592e51cb1 100644 --- a/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.h +++ b/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.h @@ -1,6 +1,22 @@ /* * AutomataUnionEpsilonTransition.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. 11. 2014 * Author: Tomas Pecka */ @@ -15,15 +31,33 @@ namespace automaton { namespace transform { /** - * Union two automata. - * - For finite automata A1, A2, we create automaton L accepting L(A1) \cup L(A2) + * Union of two finite automata. + * For finite automata A1, A2, we create a finite automaton A such that L(A) = L(A1) \cup L(A2). + * This method utilizes epsilon transitions in finite automata (Melichar: Jazyky a překlady, 2.73). */ class AutomataUnionEpsilonTransition { public: + /** + * Union of two automata using epsilon transitions. + * @tparam SymbolType Type for input symbols. + * @tparam EpsilonType Type for epsilon symbol. Defaults to DefaultEpsilonType. + * @tparam StateType Type for states. + * @param first First automaton (A1) + * @param second Second automaton (A2) + * @return epsilon nondeterministic FA representing the union of two automata + */ template < class SymbolType, class EpsilonType, class StateType > static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > unification(const automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > & first, const automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > & second); + + /** + * @overload + */ template < class SymbolType, class EpsilonType = DefaultEpsilonType, class StateType > static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > unification(const automaton::NFA < SymbolType, StateType > & first, const automaton::NFA < SymbolType, StateType > & second); + + /** + * @overload + */ template < class SymbolType, class EpsilonType = DefaultEpsilonType, class StateType > static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > unification(const automaton::DFA < SymbolType, StateType > & first, const automaton::DFA < SymbolType, StateType > & second); diff --git a/alib2algo/src/automaton/transform/AutomatonIteration.h b/alib2algo/src/automaton/transform/AutomatonIteration.h index a60ece9fc8..bedd5fb8c5 100644 --- a/alib2algo/src/automaton/transform/AutomatonIteration.h +++ b/alib2algo/src/automaton/transform/AutomatonIteration.h @@ -1,6 +1,22 @@ /* * AutomatonIteration.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: 29. 11. 2014 * Author: Tomas Pecka */ @@ -15,13 +31,25 @@ namespace automaton { namespace transform { /** - * Iterates language given by automaton - * - For finite automaton A1, we create automaton L accepting L(A1)* + * Iteration of a finite automaton. + * For finite automaton A1, we create automaton A such that L(A) = L(A1)* + * This method utilizes epsilon transitions in finite automata (Melichar: Jazyky a překlady, 2.82). */ class AutomatonIteration { public: + /** + * Iteration of a finite automaton. + * @tparam SymbolType Type for input symbols. + * @tparam StateType Type for states. + * @param automaton automaton to iterate + * @return nondeterministic FA representing the intersection of @p automaton + */ template < class SymbolType, class StateType > static automaton::NFA < SymbolType, StateType > iteration(const automaton::DFA < SymbolType, StateType > & automaton); + + /** + * @overload + */ template < class SymbolType, class StateType > static automaton::NFA < SymbolType, StateType > iteration(const automaton::NFA < SymbolType, StateType > & automaton); }; diff --git a/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h b/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h index 125ede00d4..b5440aab60 100644 --- a/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h +++ b/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h @@ -1,6 +1,22 @@ /* * AutomatonIterationEpsilonTransition.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: 29. 11. 2014 * Author: Tomas Pecka */ @@ -16,11 +32,21 @@ namespace automaton { namespace transform { /** - * Iterates language given by automaton - * - For finite automaton A1, we create automaton L accepting L(A1)* + * Iteration of a finite automaton using epsilon transitions. + * For finite automaton A1, we create automaton A such that L(A) = L(A1)* + * This method utilizes epsilon transitions in finite automata (Melichar: Jazyky a překlady, 2.84). */ class AutomatonIterationEpsilonTransition { public: + /** + * Iteration of a finite automaton. + * @tparam T Type of the finite automaton. + * @tparam SymbolType Type for input symbols. + * @tparam EpsilonType Type for epsilon symbol. Defaults to DefaultEpsilonType. + * @tparam StateType Type for states. + * @param automaton automaton to iterate + * @return epsilon nondeterministic FA representing the intersection of @p automaton + */ template < class T, class SymbolType = typename automaton::SymbolTypeOfAutomaton < T >, class EpsilonType = DefaultEpsilonType, class StateType = typename automaton::StateTypeOfAutomaton < T > > static automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > iteration(const T& automaton); }; diff --git a/alib2algo/src/automaton/transform/Compaction.h b/alib2algo/src/automaton/transform/Compaction.h index b663178110..24dfa1560a 100644 --- a/alib2algo/src/automaton/transform/Compaction.h +++ b/alib2algo/src/automaton/transform/Compaction.h @@ -1,6 +1,22 @@ /* * Compaction.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: 2. 11. 2014 * Author: Tomas Pecka */ @@ -20,14 +36,30 @@ namespace automaton { namespace transform { /** - * Transforms FSM to CompactNFA + * Transformation of a finite automaton to a compact finite automaton. + * The compact automaton allows to use strings in the transition function. The transitions are compacted. */ class Compaction { public: + /** + * Iteration of a finite automaton. + * @tparam SymbolType Type for input symbols. + * @tparam StateType Type for states. + * @param automaton automaton to compact + * @return compact nondeterministic FA equivalent to @p automaton + */ template < class SymbolType, class StateType > static automaton::CompactNFA < SymbolType, StateType > convert( const automaton::DFA < SymbolType, StateType > & automaton); + + /** + * @overload + */ template < class SymbolType, class StateType > static automaton::CompactNFA < SymbolType, StateType > convert( const automaton::NFA < 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/transform/PDAToRHPDA.h b/alib2algo/src/automaton/transform/PDAToRHPDA.h index a9d679c117..2d3cac1c2b 100644 --- a/alib2algo/src/automaton/transform/PDAToRHPDA.h +++ b/alib2algo/src/automaton/transform/PDAToRHPDA.h @@ -1,6 +1,22 @@ /* * PDAToRHPDA.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: Jan Travnicek */ @@ -15,11 +31,31 @@ namespace automaton { +/** + * Transforms a pushdown automaton to a real-time height-deterministic pushdown automaton (RHPDA). + */ class PDAToRHPDA { public: + /** + * Transformation of a PDA to a RHPDA. + * @param pda automaton to transform + * @return RHPDA equivalent to @p automaton + */ static automaton::RealTimeHeightDeterministicDPDA < > convert( const automaton::RealTimeHeightDeterministicDPDA < > & pda); + + /** + * @overload + */ static automaton::RealTimeHeightDeterministicDPDA < > convert( const automaton::DPDA < > & pda); + + /** + * @overload + */ static automaton::RealTimeHeightDeterministicNPDA < > convert( const automaton::RealTimeHeightDeterministicNPDA < > & pda); + + /** + * @overload + */ static automaton::RealTimeHeightDeterministicNPDA < > convert( const automaton::NPDA < > & pda); }; diff --git a/alib2algo/src/automaton/transform/RHPDAToPDA.h b/alib2algo/src/automaton/transform/RHPDAToPDA.h index 3dcf0fb982..0296e8523a 100644 --- a/alib2algo/src/automaton/transform/RHPDAToPDA.h +++ b/alib2algo/src/automaton/transform/RHPDAToPDA.h @@ -1,6 +1,22 @@ /* * RHPDAToPDA.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: Jan Travnicek */ @@ -16,11 +32,31 @@ namespace automaton { +/** + * Transforms real-time height-deterministic pushdown automaton (RHPDA) to a pushdown automaton (PDA). + */ class RHPDAToPDA { public: + /** + * Transformation of a RHPDA to a PDA. + * @param pda automaton to transform + * @return (non) deterministic PDA equivalent to @p automaton + */ static automaton::DPDA < > convert( const automaton::RealTimeHeightDeterministicDPDA < > & pda); + + /** + * @overload + */ static automaton::DPDA < > convert( const automaton::DPDA < > & pda); + + /** + * @overload + */ static automaton::NPDA < > convert( const automaton::RealTimeHeightDeterministicNPDA < > & pda); + + /** + * @overload + */ static automaton::NPDA < > convert( const automaton::NPDA < > & pda); }; diff --git a/alib2algo/src/automaton/transform/Reverse.h b/alib2algo/src/automaton/transform/Reverse.h index 052080e86a..21e0431af1 100644 --- a/alib2algo/src/automaton/transform/Reverse.h +++ b/alib2algo/src/automaton/transform/Reverse.h @@ -1,6 +1,22 @@ /* * Reverse.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: 7. 11. 2014 * Author: Tomas Pecka */ @@ -16,12 +32,31 @@ namespace automaton { namespace transform { +/** + * Transformation of a finite automaton to a reverse finite automaton. + * For a finite automaton A1 we create a finite automaton A such that L(A) = L(A1)^R (i.e. all strings are reversed). + */ class Reverse { public: + /** + * Iteration of a finite automaton. + * @tparam SymbolType Type for input symbols. + * @tparam StateType Type for states. + * @param automaton automaton to reverse + * @return multi-initial state nondeterministic FA accepting reversed language of @p automaton + */ template < class SymbolType, class StateType > static automaton::MultiInitialStateNFA < SymbolType, StateType > convert(const automaton::DFA < SymbolType, StateType > & automaton); + + /** + * @overload + */ template < class SymbolType, class StateType > static automaton::MultiInitialStateNFA < SymbolType, StateType > convert(const automaton::NFA < SymbolType, StateType > & automaton); + + /** + * @overload + */ template < class SymbolType, class StateType > static automaton::MultiInitialStateNFA < SymbolType, StateType > convert(const automaton::MultiInitialStateNFA < SymbolType, StateType > & automaton); }; -- GitLab